I'm writing a helper method for ASP.NET MVC and I need to call Url.Content
to get an appropriate URL for the context. However, in order to create a new UrlHelper()
I need to get the current RequestContext
(System.Web.Routing.RequestContext
to be precise) and I'm not sure how to grab it. Anyone know?
Asp.net-mvc – How to get access to the current System.Web.Routing.RequestContext from within a custom helper method in ASP.NET MVC
asp.netasp.net-mvc
Related Question
- Asp.net-mvc – How to find the absolute url of an action in ASP.NET MVC
- C# – How to handle multiple submit buttons in ASP.NET MVC Framework
- Asp.net-mvc – How to render an ASP.NET MVC view as a string
- Javascript – Change the selected value of a drop-down list with jQuery
- Asp.net-mvc – How to get ELMAH to work with ASP.NET MVC [HandleError] attribute
- Asp.net-mvc – ASP.NET MVC – Set custom IIdentity or IPrincipal
- .net – How to get the webapp’s base URL in ASP.NET MVC
- C# – How to get the client’s IP address in ASP.NET MVC
Best Solution
If the current IHttpHandler is MvcHandler, you can use