What if the httpHandlers configuration in the Linux ASP.NET MVC website is invalid?
This article mainly explains "what to do if the httpHandlers configuration is invalid in the Linux ASP.NET MVC website". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what to do if the httpHandlers configuration is invalid in the Linux ASP.NET MVC website".
I don't have time to delve into the reasons why httpHandlers is invalid. In order to solve this problem in time, I focus on the Application_BeginRequest method of Global.asax file, and then give the following solution.
First, add a static method to global.asax:
Static bool TryHanler (string ext) where T: IHttpHandler
{
If (string.IsNullOrEmpty (ext)) return false
Var context = HttpContext.Current
Var path = context.Request.AppRelativeCurrentExecutionFilePath
If (! path.EndsWith (ext)) return false
Var handle = Activator.CreateInstance (typeof (T)) as IHttpHandler
If (handle = = null) return false
Handle.ProcessRequest (context)
Context.Response.End ()
Return true
}
Note: this is a generic method. T represents a custom class inherited from IHttpHandler that you use to process a path. The parameter ext is the extension of the request path handled by this processing class (including "." Number).
Second, implement the Application_BeginRequest method in global.asax and call TryHandler in this method. Such as:
Protected void Application_BeginRequest (object sender, EventArgs e)
{
If (TryHandler (".do")) return
}
Note: the processing scheme is universal and compatible with Windows IIS and Linux Jexus or XSP at the same time.
Thank you for your reading, the above is the content of "what to do if the httpHandlers configuration is invalid in the Linux ASP.NET MVC website". After the study of this article, I believe you have a deeper understanding of how to do the invalid httpHandlers configuration in the Linux ASP.NET MVC website. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!