What’s the difference between maxRequestLength and maxAllowedContentLength

I don’t pay too much attention to what’s in the web.config so I always learn something when someone asks me how/why something works in the web.config.

When you see maxRequestLength (in system.web) and maxAllowedContentLength (in system.webServer) you ask why are 2 different attributes on length allowed.

They do serve different purposes.

maxRequestLength sets the max file upload size supported by ASP.NET.  The default size is 4096 KILOBYTES (4 MB).

maxAllowedContentLength sets the max length of content in a request supported by IIS. The default size is 30000000 BYTES (~28.6 MB).

NOTICE ONE IS IN KILOBYTES AND ONE IS IN BYTES!

Now why do you care about these settings.  If you are trying to upload large files (like images or documents) you need to be aware that you may need to adjust your maxRequestLength.  Then if files are really big you may need to adjust the maxAllowedContentLength.

What setting is the smallest takes precedence.

 

 

 

Access denied error with MVC site

If your new MVC site throws an access denied error you probably don’t have windows authentication setup.

The first thing is checking if you are hosting your site on IIS 7 or better. (Otherwise this section won’t help).
Right click on your project in Visual Studio, click Properties.
Click the web tab.
If you Use IIS Express checked THEN SKIP TO THE BOTTOM OF THIS ARTICLE.
image

Open IIS Manager (Start –> Administrative Tools –> Internet Information Services (IIS) Manager).
Navigate to your website (usually Default Web Site) and click on it.
image

Double click Authentication.
If you don’t see Windows Authentication then it’s not setup.
image

See this post about enabling windows authentication.
(You may need to close IIS Manager and reopen it).

4. In the Actions pane, click Enable to use Windows authentication.
image

5. On the Authentication page, select Anonymous authentication.

6. In the Actions pane, click Disable to disable anonymous authentication.
image

Here is how to enable windows authentication on IIS Express in Visual Studio 2012.
1. Click on your project in the Solution Explorer to select the project.
2. If the Properties pane is not open, open it (F4).
3. In the Properties pane for your project:
a) Set “Anonymous Authentication” to “Disabled”.
image

b) Set “Windows Authentication” to “Enabled”.
image

[tweetmeme only_single=”false”]

How to setup windows authentication on Windows

Here on the steps to enable windows auth on Windows 7:
a) In Control Panel open “Programs and Features”.
image

b) Select “Turn Windows features on or off”.
image
c) Navigate to Internet Information Services > World Wide Web Services > Security
and make sure the Windows authentication node is checked.
image

To enable Windows authentication on Windows Server:
a) In Server Manager, select Web Server (IIS) and click Add Role Services.
b) Navigate to Web Server > Security
and make sure the Windows authentication node is checked.

[tweetmeme only_single=”false”]

Enable IIS 6 Compression

So I copied this post from a coworker of mine, Dennis Bottjer

IIS compression makes a huge difference and it’s an easy batch file to set it up.

 

How to Enable IIS 6.0 Compression for SharePoint:

Microsoft’s Internet Information Server (IIS) has long support HTTP Compression.  However, supporting and implementing compression are two different things.  Many settings within IIS are easily configured from the IIS Admin GUI.  Unfortunately, enabling and configuring compression is not supported through the GUI and requires editing the IIS Metabase.  THe metabase can be edited manually or updated from a command prompt.  The commands can be combine into the following script:

Script:

cd c:\inetpub\adminscripts

REM Turn On Compression
cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoDynamicCompression true
cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true

REM Set Compression to High Level
cscript.exe adsutil.vbs set w3svc/filters/compression/gzip/hcdynamiccompressionlevel "9"
cscript.exe adsutil.vbs set w3svc/filters/compression/deflate/hcdynamiccompressionlevel "9"

REM IIS 6.0 Only

REM cscript.exe adsutil.vbs set w3svc/filters/compression/gzip/hcscriptfileextensions "css" "js" "asp" "exe" "axd" "aspx"
REM cscript.exe adsutil.vbs set w3svc/filters/compression/deflate/hcscriptfileextensions "css" "js" "asp" "exe" "axd" "aspx"

iisreset
pause

Recommendations:

File Extensions:

Consider Adding: “ascx”, “ashx”, “asmx” “xml”

Testing:

Test the various file extensions and compression levels.  Perhaps start with a compression level of 7 to 8 or 9 after monitoring CPU utilization.  The results of compression can be monitored using Fiddler.