I have an MVC4 application with Membership logon (through FormsAuthentication).
This is defined in web.config as follows. My default url is home root (~/):
<roleManager enabled="true" />
<authentication mode="Forms">
<forms defaultUrl="~" loginUrl="~/Account" />
</authentication>
In my AccountController in the Login post method, following code is relevant. This code is executed when the user clicks on the login with valid credentials.
if (Membership.ValidateUser(creds.Username, creds.Password))
{
FormsAuthentication.RedirectFromLoginPage(creds.Username, false);
return null;
}
Now, if I'm navigating (anonymously) to: ~/Admin, I get redirected to ~/Account to log in, which is perfect. I can see that the url is formed as follows:
http://localhost:23759/Account?ReturnUrl=%2fAdmin
But, when I succesfully login, I get redirected to home (~/) instead of ~/Admin
Please help! Many thanks!
Edit: Found the actual issue: it was the post method that wasn't receiving the querystring