Answer the question
In order to leave comments, you need to log in
What is the best way to do something like Url.Action in an attribute on the server side in MVC?
What is the best way to do something like Url.Action in an attribute on the server side in MVC?
Do I need to write a method that takes a UrlActionDescriptor and returns a string, or is there a better solution?
filterContext.Result = new RedirectResult(Url.Action(NameHelper.CustomName));
Answer the question
In order to leave comments, you need to log in
Redirection can be done like this:
HttpContext.Current.Response.RedirectToRoute
(
new
{
controller = "Home",
action = "Index"
}
);
var urlHelper = new System.Web.Mvc.UrlHelper(HttpContext.Current.Request.RequestContext);
var url = urlHelper.Action("Index", "Home");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question