Description:I have a simple application in asp.net mvc 4 with my controller method for login is with attribute [AllowAnonymous] and I want my users to redirect to same page from which they have been redirected to the login page. I have seen some article which suggests that I need to pass the returnurl in the query string but did't get the complete process of implementing the feature.
kindly suggests a complete solution!
Posted by: Khalid Abbas | Posted on: Jul 30, 2018
4
Your controller get method will be like the following method taking the returnUrl as input parameter and setting it to the viewbag.
Now in your MVC view you will be setting the ViewBag.ReturnUrl to ReturnUrl parameter of beginForm as shown below.
Now in your controller post method you will take the your LoginModel as well as returnUrl as an extra parameter.
Following method is called in above controller method to make sure that the returnUrl is local url.
Replied by: Junaid Aziz | Replied on: Aug 28, 2018