Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC Forms LoginUrl is incorrect

I have an ASP.NET MVC 3 application with forms authentication. For some reason that I cannot see, the login redirect url is /Account/Login?ReturnUrl=%2fSecure%2fAction instead of /Account/LogOn?ReturnUrl=%2fSecure%2fAction. The difference is subtle, its using /Account/Login instead of /Account/LogOn.

My web.config forms section is correct. Would else could possibly affect the login url??

<authentication mode="Forms">   <forms loginUrl="~/Account/LogOn" timeout="720" /> </authentication> 
like image 942
jrummell Avatar asked May 20 '11 14:05

jrummell


1 Answers

This is a known issue. I had the same problem with my custom authorize attribute. I found the solution somewhere on the net, can't remember where. Just add this to appSettings in your web.config

<add key="loginUrl" value="~/Account/LogOn" /> 

Note: This works with MVC 3, I didn't try it with previous versions.

EDIT: Found it mentioned in release notes, but it seems that they've changed the setting name and forgot to update release notes for RTM version.

like image 95
frennky Avatar answered Oct 06 '22 01:10

frennky