ASP.NET MVC 4 intercept all incoming requests

前端 未结 4 958
粉色の甜心
粉色の甜心 2020-11-27 02:50

Is there a way for me to catch all incoming requests to my ASP.NET MVC 4 app and run some code before continuing the request onward to the specified control

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 03:37

    I think that what you search for is this:

    Application_BeginRequest()
    

    http://www.dotnetcurry.com/showarticle.aspx?ID=126

    You put it in Global.asax.cs.

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            HttpContext.Current.Request.....;
        }
    

    I use this for debugging purposes but I am not sure how good solution it is for your case.

提交回复
热议问题