web-config
Specify more than one directory in Web.Config’s Location Path element
You cannot specify multiple elements in the path attribute, but you can make use of the configSource attribute. For example, the following original web.config file: <?xml version=”1.0″?> <configuration> <location path=”form1.aspx”> <system.web> <authorization> <allow users=”*”/> </authorization> </system.web> </location> <location path=”form2.aspx”> <system.web> <authorization> <allow users=”*”/> </authorization> </system.web> </location> <location path=”form3.aspx”> <system.web> <authorization> <allow users=”*”/> </authorization> </system.web> </location> … Read more
How to enable GZIP compression in IIS 7.5
GZip Compression can be enabled directly through IIS. First, open up IIS, go to the website you are hoping to tweak and hit the Compression page. If Gzip is not installed, you will see something like the following: “The dynamic content compression module is not installed.” We should fix this. So we go to the … Read more
upgrading from MVC4 to MVC5
Found out what need to be done in Views\Web.config. Just copy & paste these sections over what you have: <configSections> <sectionGroup name=”system.web.webPages.razor” type=”System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″> <section name=”host” type=”System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″ requirePermission=”false” /> <section name=”pages” type=”System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″ requirePermission=”false” /> </sectionGroup> </configSections> <host factoryType=”System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″ /> <pages … Read more
How to read appSettings section in the web.config file?
Since you’re accessing a web.config you should probably use using System.Web.Configuration; WebConfigurationManager.AppSettings[“configFile”]
Unrecognized attribute ‘targetFramework’. Note that attribute names are case-sensitive
The problem could be: the Application Pool for your site is configured for .NET Framework Version = v2.0.XXXXX .NET 4 isn’t installed on your server. See also Unrecognized attribute ‘targetFramework’ … How to add ASP.NET 4.0 … … which helped me fix a similar issue.
web.config and app.config confusion
Create a new sectionGroup in configSections called applicationSettings and paste your app.config configuration into web.config as shown below and then you can override your app.config settings. <?xml version=”1.0″ encoding=”utf-8″ ?> <configuration> <configSections> <sectionGroup name=”applicationSettings” type=”System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ > <section name=”Playground.ConfigurationOverride.DataAccess.Properties.Settings” type=”System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ requirePermission=”false” /> </sectionGroup> </configSections> <applicationSettings> <Playground.ConfigurationOverride.DataAccess.Properties.Settings> <setting name=”MySetting” … Read more
How to add namespaces in web.config file?
You need to put them in the correct <system.web> section. e.g.: <configuration> <system.web> <pages> <namespaces> <add namespace=”System.Data” /> <add namespace=”System.Text”/> </namespaces> </pages> </system.web> </configuration> and put them in the correct web.config i.e. the second web.config file is the Views folder and is specific to views. These settings do not go in the root web.config. The … Read more
Remove “Server” header from ASP.NET Core 2.1 application
This solution works on IIS 10+ version and allows to remove x-powered-by and server headers in server response. In IIS 10 a new attribute was added: removeServerHeader. We need to create web.config file in asp.net core application with following content: <?xml version=”1.0″ encoding=”utf-8″?> <configuration> <system.webServer> <security> <requestFiltering removeServerHeader=”true” /> </security> <httpProtocol> <customHeaders> <remove name=”X-Powered-By” /> … Read more