Sunday, December 3, 2017

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

Good day!
I was trying to apply integrate an Image HttpHandler that discourages leeching from one of my Web Forms project to ASP.NET MVC. This hack is found on ASP.NET 2.0 MVP Hacks site. Upon running the ASP.NET MVC project, an issue was thrown to the browser specifically "HTTP Error 500.23 - Internal Server Error. An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode." Upon investigating, I found out that handlers in WebForms are declared in <httpHandlers> under <system.web>.
<system.web>
 <httpHandlers>
  <add verb="*" path="*.jpg" type="Events.Web.Extensions.NoLeechImageHandler"/>
  <add verb="*" path="*.jpeg" type="Events.Web.Extensions.NoLeechImageHandler"/>
  <add verb="*" path="*.gif" type="Events.Web.Extensions.NoLeechImageHandler"/>
  <add verb="*" path="*.png" type="Events.Web.Extensions.NoLeechImageHandler"/>
 </httpHandlers>
</system.web> 
And handlers in MVC are set inside the <handlers> node belonging to <system.webServer>.
<system.webServer>
 <handlers>
   <add name="jpgHandler" verb="*" path="*.jpg" type="Events.Web.Extensions.NoLeechImageHandler"/>
   <add name="jpegHandler" verb="*" path="*.jpeg" type="Events.Web.Extensions.NoLeechImageHandler"/>
   <add name="gifHandler" verb="*" path="*.gif" type="Events.Web.Extensions.NoLeechImageHandler"/>
   <add name="pngHandler" verb="*" path="*.png" type="Events.Web.Extensions.NoLeechImageHandler"/>
 </handlers>
</system.webServer>
That fixed the issue for ASP.NET MVC.

0 comments:

Post a Comment