Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to understand System.Web.HttpNotFoundHandler

I need to restrict access to all but one view in my ASP.NET MVC4 project on our public site. We have to prevent a login screen from appears because AD is not setup on our public server as well.

From what I've read about System.Web.HttpNotFoundHandler, the way I understand it is if I include the following line in my web.config all cshtml pages in my /Views folder will be restricted from view:

<httpHandlers>
    <add path="*.cshtml" verb="*" type="System.Web.HttpNotFoundHander"/>
</httpHandlers>

However, when I play around with this setting in both of my web.config files, nothing is restricted from view on my local machine when I test. I have my program setup to run on my local IIS7 (our public site is IIS6). I feel I misunderstand how this works.

like image 604
EscapeChar Avatar asked Aug 27 '26 16:08

EscapeChar


1 Answers

For IIS 6

<httpHandlers>
    <add path="*.cshtml" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>

For IIS 7

<httpHandlers>
    <add name="BlockViewHandler" path="*.cshtml" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>

To deep dive in this topic read This Blog

like image 133
Curiousdev Avatar answered Aug 31 '26 01:08

Curiousdev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!