ReturnUrl = Default.aspx for MVC?

I am trying to secure my entire MVC site, so I added the [Authorize] attribute in front of the Home controller.

Now if you launch it from Visual Studio or go to the root url (for example http: // localhost: 2897 ), it redirects to the login page as expected. However, the url in the address bar after the redirect looks like this: http: // localhost: 2897 / Account / LogOn? ReturnUrl =% 2fdefault.aspx% 3f

I haven't tested this because I haven't implemented my authentication code. However, this looks like a big problem to me since I don't have a default.aspx in my project!

My authentication tag in web.config looks like this:

<authentication mode="Forms">
   <forms loginUrl="~/Account/LogOn" defaultUrl="~/Home/Index" timeout="2880"/>
</authentication>

      

Why doesn't it choose this route as the default ReturnUrl instead of default.aspx?

+2


a source to share


1 answer


ASP.NET (to be precise FormsAuthentication.RedirectFromLoginPage

) always ignores the parameter defaultUrl

in web.config

when the parameter is present ReturnUrl

. This is only done by going directly to the login page without going through any parameters ReturnUrl

.



The ASP.NET MVC Project Template provides a blank template Default.aspx

for handling requests such as IIS Classic pipeline mode. You should be fine with this.

+2


a source







All Articles