Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

How do i redirect to same login page with same url string
If the login fails for the user.

http://localhost:8080/Authenticate/Login?&ReturnUrl=%2fAuthenticate%2fUserProfile%2f1[^]
Posted
Comments
Thomas Nielsen - getCore 2-Apr-14 8:00am    
Are you using forms authentication?
Code Help 2014 2-Apr-14 9:28am    
The question is not clear. If you want to redirect to same page where you are checking the login, then you don't need to redirect. The user will automatically remain on the same page. So clarify your question.

You can use Response.Redirect. For the controller you can add a parameter for authenticate:

public ActionResult Login(string ReturnUrl)
{
    Response.Redirect("/Authenticate/Login?" + ReturnUrl);
}
 
Share this answer
 
On Button click event of login, on login fail write response.redirect("loginpageurl").
 
Share this answer
 
Comments
[no name] 2-Apr-14 9:00am    
i have to get the url with returnurl in querystring if the login fails for wrong password or somthing else.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900