It would be simple enough, it would seem, but this is not so - mainly due to the fact that View cannot know which path through the model and controller you got there. Despite this, this is a problem that needs to be resolved:
I have a login link in which the user enters a username and password. When the user clicks "send", I want to redirect to the page that he was viewing. The easiest way to do this seems to indicate the url of the current page as querystring ( ...?returnUrl=... ), and everything else is already built.
But where can I find this url from my view when rendering the link? Naturally, I cannot use RedirectToActionResult, since I do not want to actually translate the user - just display the URL in the link. How?
EDIT:
Now I have begun generosity on this issue, and therefore I consider it necessary to clarify my needs.
I have a UserControl named Login.ascx in my shared folder. In it, I do an ActionLink for the login form and is included in the footer on my main page. I want to do the following:
When an ActionLink is rendered, a route to the view that is currently displayed is added to the querystring returnUrl . If this is done, the user will be returned to the page that he viewed after a successful login, with features that are already built into the ASP.NET MVC Framework.
The reason the previous answers were insufficient is mainly because they did not provide a way to construct the route URL for the current view . I know how to add a query, but I do not know how to find out what to put on this line.
To mark the answer as the answer, I want the method to rebuild the route in the current view shown from the user control on the main page.
asp.net-mvc url-routing
Tomas lycken
source share