I have a url that looks like this
http://mysite/account/login?returnurl=/Event/Details/41
and returnUrl = "/Event/Details/41"
I need to get the route values from return url - which includes the EventID = 41
I was able to get the event Id using this code:
public ActionResult Login()
{
....
string returnUrl = Request.QueryString["ReturnUrl"];
int lastIndex = returnUrl.LastIndexOf("/") + 1;
string strEventID = returnUrl.Substring(lastIndex);
int EventID = Int32.Parse(strEventID);
....
}
But I feel there could be a more flexible way that would give me access to querystrings, route values, etc, without manually doing it this way.
I dont't want to use WebRequest, WebClient and blah blah, just looking for MVC related solution or something simpler.