Which gets priority, maxRequestLength or maxAllowedContentLength?

maxRequestLength indicates the maximum request size supported by ASP.NET, whereas maxAllowedContentLength specifies the maximum length of content in a request supported by IIS. So you need to set both in order to upload large files: the smaller one “takes priority”. (I picked this up from http://forums.iis.net/t/1169846.aspx — credit where it’s due.) You can set both … Read more

How to increase request timeout in IIS?

Add this to your Web Config <system.web> <httpRuntime executionTimeout=”180″ /> </system.web> https://msdn.microsoft.com/en-us/library/e1f13641(v=vs.85).aspx Optional TimeSpan attribute. Specifies the maximum number of seconds that a request is allowed to execute before being automatically shut down by ASP.NET. This time-out applies only if the debug attribute in the compilation element is False. To help to prevent shutting down … Read more

Avoid web.config inheritance in child web application using inheritInChildApplications

As the commenters for the previous answer mentioned, you cannot simply add the line… <location path=”.” inheritInChildApplications=”false”> …just below <configuration>. Instead, you need to wrap the individual web.config sections for which you want to disable inheritance. For example: <!– disable inheritance for the connectionStrings section –> <location path=”.” inheritInChildApplications=”false”> <connectionStrings> </connectionStrings> </location> <!– leave inheritance … Read more

How to configure the web.config to allow requests of any length

Add the following to your web.config: <system.webServer> <security> <requestFiltering> <requestLimits maxQueryString=”32768″/> </requestFiltering> </security> </system.webServer> See: http://www.iis.net/ConfigReference/system.webServer/security/requestFiltering/requestLimits Updated to reflect comments. requestLimits Element for requestFiltering [IIS Settings Schema] You may have to add the following in your web.config as well <system.web> <httpRuntime maxQueryStringLength=”32768″ maxUrlLength=”65536″/> </system.web> See: httpRuntime Element (ASP.NET Settings Schema) Of course the numbers (32768 … Read more

How to force HTTPS using a web.config file

You need URL Rewrite module, preferably v2 (I have no v1 installed, so cannot guarantee that it will work there, but it should). Here is an example of such web.config — it will force HTTPS for ALL resources (using 301 Permanent Redirect): <?xml version=”1.0″ encoding=”UTF-8″?> <configuration> <system.webServer> <rewrite> <rules> <clear /> <rule name=”Redirect to https” … Read more

Access-control-allow-origin with multiple domains

For IIS 7.5+ and Rewrite 2.0 you can use: <system.webServer> <httpProtocol> <customHeaders> <add name=”Access-Control-Allow-Headers” value=”Origin, X-Requested-With, Content-Type, Accept” /> <add name=”Access-Control-Allow-Methods” value=”POST,GET,OPTIONS,PUT,DELETE” /> </customHeaders> </httpProtocol> <rewrite> <outboundRules> <clear /> <rule name=”AddCrossDomainHeader”> <match serverVariable=”RESPONSE_Access_Control_Allow_Origin” pattern=”.*” /> <conditions logicalGrouping=”MatchAll” trackAllCaptures=”true”> <add input=”{HTTP_ORIGIN}” pattern=”(http(s)?://((.+\.)?domain1\.com|(.+\.)?domain2\.com|(.+\.)?domain3\.com))” /> </conditions> <action type=”Rewrite” value=”{C:0}” /> </rule> </outboundRules> </rewrite> </system.webServer> Explaining the server variable … Read more

What is the difference between customErrors and httpErrors?

*Updated April 2016 The customErrors attribute is used when the .net code is throwing an exception (404, 403, 500 etc) and the httpErrors attribute is used when IIS itself is throwing an exception. /myfakeextensionslessurl –> httpErrors 404 /myfakeaspsx.aspx –> customErrors 404 /myfakeimage.jpg –> httpErrors 404 /throw500.apx –> customErrors 500 /throw500 –> customErrors 500 There are … Read more

Change a web.config programmatically with C# (.NET)

Here it is some code: var configuration = WebConfigurationManager.OpenWebConfiguration(“~”); var section = (ConnectionStringsSection)configuration.GetSection(“connectionStrings”); section.ConnectionStrings[“MyConnectionString”].ConnectionString = “Data Source=…”; configuration.Save(); See more examples in this article, you may need to take a look to impersonation.