Reputation: 571
Is there a way to link to an internal Url in mvc5?
I get the url like so: Source = Request.RawUrl
this returns: "/Clients/AddNote"
but it can also have parameters: "/Clients/AddNote/12?items=10"
This is the code that i have so far:
string[] url = Source.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
string Controller = url[0];
string Action = url[1];
try{
string id = url[2];
return RedirectToAction(Action, Controller, new { id = id});
}
catch{}
return RedirectToAction(Action, Controller);
this works good when there is only an ID ad parameter but this code does not handle the named parameters like: ?items=10
is there a way that i can just say: return RedirectToAction("/Clients/AddNote/12?items=10");
?
Upvotes: 1
Views: 1420