The situation is that I want all the file types to be handled by a specified dll except 'aspx' file.
But I don't know how to edit the configuration file. As below:
<system.web>
<httpHandlers>
<add verb="*" path="*" type="My.Handler" />
</httpHandlers>
</system.web>
All the requests will be handled by My.Handler. How to make the aspx file be accessed normally?
I have a "work around", but it's kind of "hacky" (and I only tested it locally as well)...
1. Create the class below:
public class PassThroughAspxHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
var pageInstance = PageParser.GetCompiledPageInstance(context.Request.AppRelativeCurrentExecutionFilePath,
context.Request.PhysicalApplicationPath + context.Request.Path,
context);
pageInstance.ProcessRequest(context);
}
public bool IsReusable
{
get { return false; }
}
}
2. Add the entry to your web config below: (this part is for IIS7 integrated app pools, it will be slightly different if you are using a classic app pool):
<system.webServer>
<handlers>
<add verb="*" path="*.aspx"
name="PassThroughAspxHandler"
type="YourNameSpaceHere.PassThroughAspxHandler"/>
</handlers>
</system.webServer>
Just a guess but try adding this after the one you came up with:
<add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With