Reputation: 168
How can we redirect to a particular action using System.Uri
public ActionResult Edit(MyModel model)
{
Uri url = System.Web.HttpContext.Current.Request.UrlReferrer;
if (condition)
{
return View(url);
}
return View(model);
}
i want to redirect the page to url
Please help
Upvotes: 2
Views: 2655
Reputation: 101150
There is a Redirect()
method which takes an url.
The trick is to convert it to a string
first as the Redirect()
method do not take an Uri
object:
public ActionResult Edit(MyModel )
{
Uri url = System.Web.HttpContext.Current.Request.UrlReferrer;
if (condition)
{
return Redirect(url.ToString());
}
return View(model);
}
Upvotes: 5