views:

176

answers:

4

Is there any way to make some sections of the web.config file only apply to a single file (or directory, or a group of files, etc.)

Basically I would like to apply the following thing only to a single page in the application, the rest should use the default settings: (it limits the upload size to 32M)

<system.web>
  <httpRuntime maxRequestLength="32768" executionTimeout="360"/>
</system.web>

The point is that I only want that particular page to accept large files.

+3  A: 

You can place a web.config file on any directory of your web application, what you define there will only work for that directory and bellow

Sergio
+1  A: 

You can also try it with the <location> tag, however I'm not sure you can use it with <httpRuntime>.

csgero
+7  A: 

You can use:

  <location path="UploadPage.aspx">
    <system.web>
      <httpRuntime maxRequestLength="33554432" executionTimeout="360" />
    </system.web>
  </location>

More info here.

Eduardo Campañó
Thanks man, you have won an internet
DrJokepu
Just what I was looking for +1
Kb
A: 

Yea use the <location path="..."> element to achieve this. The path might point to a directory as well as a file. You will need to set allowDefinition="everywhere".

baretta