How can I, when executing a controller action, take a Uri (not the one requested) and invoke the action from the controller that would have been executed had that Uri been the one that was called? I can't simply redirect to that action as I need it to happen in the same request context.
相关问题
- Carriage Return (ASCII chr 13) is missing from tex
- MVC-Routing,Why i can not ignore defaults,The matc
- How to store image outside of the website's ro
- 'System.Threading.ThreadAbortException' in
- Request.PathInfo issues and XSS attacks
相关文章
- asp.net HiddenField控件扩展问题
- asp.net HiddenField控件扩展问题
- Asp.Net网站无法写入错误日志,测试站点可以,正是站点不行
- asp.net mvc 重定向到vue hash字符串丢失
- FormsAuthenticationTicket expires too soon
- “Dynamic operations can only be performed in homog
- What is the best way to create a lock from a web a
- Add to htmlAttributes for custom ActionLink helper
Assuming you have access to the HttpContext (and I suppose you do since you are asking) you could:
Personally I use this approach for handling errors inside my application. I put this in
Application_Error
and execute an error controller for custom error pages staying in the context of the initial HTTP request. You could also place complex objects inside therouteData
hash and you will get those complex objects back as action parameters. I use this to pass the actual exception that occurred to the error controller action.UPDATE:
In order to parse an URL to its route data tokens taking into account current routes you could:
For the correct answer, I'd prefer do something like this to let MVC handle creating controllers rather than creating myself.
This would assure you that your Foo controller is getting the same behavior as other controllers.
Any reason you can't push the code you are calling into a controller-independent class? Cross-calling controllers sounds like a bit of a WTF to me.