maxRequestLength is in KB
- unspecified default: 4096 or 4MB
- Specifies the maximum content length of a request to be supported by ASP.NET
- example usage for 50MB limit in a website project: edit web.config
<configuration>
<system.web>
<httpRuntime maxRequestLength="51200" />
</system.web>
</configuration>
maxAllowedContentLength is in B
- unspecified default: 30000000 or ~28.6MB
- Specifies the maximum content length of a request to be supported by IIS
- example usage for 50MB limit in a website project: edit web.config
<configuration>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="51200000" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
This method can be used to fix duplicate content errors and make it so google only indexes one version of your urls, which will prevent you from getting a negative modifiers.
In order to do this you have two options.
- Use the proper canonical tags, for example place the following code at the top of your website:
- Use the following script to automate the process and only allow lower case urls to be viewed on your site, create a global.asax file and place it in your site's main directory.
If you plan to use both methods be sure to use only lower case for your canonical tags or you will end up with problems.
If you are getting this error:
Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
First check that you have Microsoft.Web.Extensions.dll and Microsoft.Web.Extensions.Design.dll in your bin folder. Also check that you are using the correct version of .net in IIS.
If non of these solutions work then verify that if application is in a folder other than root you make this folder an application in IIS. Right click folder "convert to application".
The most effective method will be to use the global.asax file, here is a basic example:
<script language="C#" runat="server">
protected void Application_BeginRequest(Object sender, EventArgs e) {
if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("http://"))
{
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", Request.Url.ToString().ToLower().Replace("http://","https://"));
}
}
</script>
In some cases you may already have an application using the global.asax file, you can in many cases add the _BeginRequest function or adapt it if it already exists. For example add this after the <script runat="server"> tag but before any other code.
protected void Application_BeginRequest(object sender, EventArgs e) {
if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("http://")) {
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", Request.Url.ToString().ToLower().Replace("http://","https://"));
}
In some cases this will throw and error, before sure to check the rest of the global.asax file for any other begin requests that may be conflicting. In some cases you may need to adapt the code to work in parallel with exiting code.
Related Errors:
HTTP Error 401.3 Unauthorized
You do not have permission to view this directory or page because of the access control list (ACL) configuration or encryption settings for this resource on the Web server.
Simple to fix,
- Open IIS
- Select the main web tree or spacific website if its only one
- select authentication, then click edit on the right
- change it from spacific user to app pool identity
Done!
Error:
HTTP Error 505.19 Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Simple to fix,
Done!