Thursday, September 27, 2012

Increase File Upload Size in asp.net using Command Prompt

You can run the following from a command prompt while in the C:\Inetpub\AdminScripts directory instead of editing the Metabase.xml file directly as mentioned in above method.

1. At a command prompt, type the following command, & then press ENTER:
cd C:
cd C:\Inetpub\AdminScripts
2. At a command prompt, type the following command, & then press ENTER to check the current upload limit:

cscript adsutil.vbs get w3svc/ASPMaxRequestEntityAllowed

C:\Inetpub\AdminScripts>cscript adsutil.vbs get w3svc/ASPMaxRequestEntityAllowed

Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

ASPMaxRequestEntityAllowed : (INTEGER) 204800
It displays the current/present value that is set to 204800 ie: 200KB.

3. Now to change the value to any higher one, run the following command:

cscript adsutil.vbs set w3svc/ASPMaxRequestEntityAllowed size

In this command, size is a placeholder for the largest file size upload that you want to allow. The maximum value is 1,073,741,824 bytes. Set this value to the lowest possible value that allows for the functionality that you want.

To change the value to 100MB, run the following command:cscript adsutil.vbs set w3svc/AspMaxRequestEntityAllowed 104857600
C:\Inetpub\AdminScripts>cscript adsutil.vbs set w3svc/AspMaxRequestEntityAllowed 104857600
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

AspMaxRequestEntityAllowed : (INTEGER) 104857600
4. Run iisreset /restart to restart the web services & for the changes to come into effect.

You can confirm the changes by checking the ASPMaxRequestEntityAllowed using the GET command [as in step 2]:
C:\Inetpub\AdminScripts>cscript adsutil.vbs get w3svc/ASPMaxRequestEntityAllowed
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

ASPMaxRequestEntityAllowed : (INTEGER) 104857600
The example above updates the metabase.xml file & sets the maximum uploadable value to 100MB

No comments:

Post a Comment