How do I execute a controller action from an HttpModule in ASP.NET MVC?

后端 未结 4 1244
遥遥无期
遥遥无期 2021-01-03 16:20

I\'ve got the following IHttpModule and I\'m trying to figure out how to execute an action from a controller for a given absolute or relative URL.



        
4条回答
  •  一向
    一向 (楼主)
    2021-01-03 16:48

    I think you need to use HttpContext.Current.RewritePath

    This lets you change the path for the file you want to use. It's what the default.aspx created in MVC 2 projects does.

    I've used it in much the same way you are, to do error handling without a 302 but can't get to my code right now. I'll post some code on Monday.

提交回复
热议问题