Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if the httpHandlers configuration in the Linux ASP.NET MVC website is invalid?

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report