By using a default MVC 4 web application how can I redirect the user to certain page if he is logged in? What I mean when you try to access a page that is decorated with [Authorize]
attribute, it will redirect you to login page and the parameter in the url is the page you tried to access. If login succeeded, you will be redirected to that specific page. Now you are authenticated and you can access that specific page. But if you go back to the login page http://page:port/Account/Login
it will still display the login page. How can I redirect the user from login page if he/she is already loged in?
Should I use this in the controller GET Login action
from Account Controller?
if(Request.IsAuthenticated)
{
...redirect to ...
}
Simply enter a login URL and logout URL into the 'All Other Users' section. Then, click the 'Save Changes' button. When a new user signs up on your website, WordPress redirects them to the login page. You can set up a redirect URL to send them to any other page on your website.
RedirectToAction is meant for doing 302 redirects within your application and gives you an easier way to work with your route table. Redirect is meant for doing 302 redirects to everything else, specifically external URLs, but you can still redirect within your application, you just have to construct the URLs yourself.
You can use RedirectToAction
in your controller like this:
if(Request.IsAuthenticated)
{
return RedirectToAction("Index","Home");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With