It appears to be quite simple, but it did not come out - mainly because of the fact that the view can not possibly be known Even if you go through which model and controller there, this is a problem which needs solutions:
I have a login link, which will allow the user to enter the user name and password. takes away. When the user clicks on "submit", I want to redirect to the page he was looking at. The easiest way to do this is to specify the URL as the current page in the form of a page ( ... ... returnUrl = ...
) and everything else has already been made .
But when I consider the URL, from where I think this URL should be used? I can not use a RedirectToActionResult naturally because I do not really want to transfer the user - how to present the URL in only one link?
Edit:
I have now started a reward on this question, and so I am fit to clarify my needs too.
Login to my shared folder is a UserControl named .ascx. In it, I present an application link in the login form, and it is included in the footer on my masterpage. What I want to accomplish is the following:
When ActionLink is provided, the querystressing returnUrl
is added to with this view that is currently presented Is being done . If it is complete, the user will be taken back to the page that was looking after a successful login with the functionality that is already built in the ASP.NET MVC framework.
The reason for past replies is adequately enough that they have not provided a way to create the Root URL for the current view I know that How to add a query string, but I do not know what to put in that string.
To mark the answer as as an answer, I want a method to rebuild the path in the scene currently shown, in the masterpage From user control
The solution is to use HttpContext.Current.Request.RawUrl:
& lt;% = Html.ActionLink ("Log on", "Login", new {controller = "user", ReturnUrl = HttpContext.Current.Request.RawUrl})%>
Or (with Microsoft.Web.Mvc.dll) with an extension method:
& lt;% = HTML.ActionLink & lt; AccountController & gt; (C = & Gt; c.LogOn ("name", "password", false, http console. Current request request URL), "login here")% & gt;
The default in the action controller MVC, but just add the return URL to your own.
Comments
Post a Comment