Quantcast
Channel: All Forums
Viewing all articles
Browse latest Browse all 28058

How do I disable the default handler HttpForbiddenHandler for .cs files?

$
0
0

I want to be able to view the code behind files from the browser while in the development stage. To do this, I would need to disable the default handler of.cs files, HttpForbiddenHandler, in the web.config.

Since I am using IIS 7, I first placed the <remove> element in <system.webServer> section like this:

<system.webServer><handlers><remove path="*.cs" verb="*"/><add verb="*" path="*.cspx" type="HandlersAndModules.CspxHandler, HandlersAndModules" name="CspxHandler"/></handlers></system.webServer>

and I got the error when I run the application:

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

This is because the <remove> element in <handlers> in <system.webServer> section does not recognize attributes 'verb' and 'path'.

Then I tried moving <remove> element to <system.web> section like this:

<system.web><httpHandlers><remove path="*.cs" verb="*"/></httpHandlers></system.web>

and I got the error when I run the application:

HTTP Error 500.23 - Internal Server Error
An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

How do I disable the default handler HttpForbiddenHandler that prevents.cs files from being viewed from the browser?

Please note that I am aware that this is to be done only in local development machines. I got this idea from an old MSDN article: Serving Dynamic Content with HTTP Handlers


Viewing all articles
Browse latest Browse all 28058

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>