Reputation: 21265
I created my own login logic for a set of web applications. A future version of this project will have a portal-like interface which would then utilize the ASP.NET MVC login logic.
One thing I am trying to figure out is how to build a return URL dynamically based on what controller/action I am in. I am currently doing:
public ActionResult Action(LogggedInCustomer logIn, string id)
{
if (logIn == null)
return RedirectToAction("Index", "Home",
new { returnUrl = "/AR/Invoice/Print/" + id });
}
The application will reside in a folder on the server (domain.com/app). I want to build the return UL more dynamically (if possible). How would I do this?
Upvotes: 3
Views: 3050
Reputation: 1038890
By using the Url property:
public ActionResult Action(LogggedInCustomer logIn, string id)
{
if (logIn == null)
{
var returnUrl = Url.Action("Print", "Invoice", new { area = "AR", id = id });
return RedirectToAction("Index", "Home", new { returnUrl = returnUrl });
}
...
}
Upvotes: 4