I have the following config that I would like to remove from web config and only enforce in code for a certain page 'Page1.aspx', else the configuration would apply across all pages.
How would I specify this configuration or enforce it through code, so it applies to only Page1.aspx?
<system.web>
<browserCaps>
<case>
RequiresControlStateInSession=true
</case>
</browserCaps>
</system.web>
I just found a way to mention configuration on a page basis, so the configuration only applies to that page.
Just include any specific configuration under a <location>
element that you would like to apply to a single page. Keep the following points in mind when using this approach:
path
attribute of the <location>
element. It can be a relative path.<location>
element must be outside the <system.web>
, <system.webserver>
, and any other sections within Web.config.In my case the following worked, where I specified a <location>
section for the single page for which I wanted to specify special configuration:
<?xml version="1.0"?>
<configuration>
<!-- all sections in web config go here. Put the Location elements always
at end of your web config file -->
<location path="Page1.aspx">
<system.web>
<browserCaps>
<case>
RequiresControlStateInSession=true
</case>
</browserCaps>
</system.web>
</location>
</configuration>