0

I'm having a bit of trouble using Forms Authentication in MVC whenever the redirect has to occur within an area.

MembershipControlller

  • Login

This is the routing. So ... /Membership/Login is the URL. In my Web.config file, I have this set as such...

    <authentication mode="Forms">
        <forms loginUrl="/Membership/Login" timeout="2880" protection="Encryption" />
    </authentication>

Also note, I have tried the variant "~/Membership/Login"

Now this works fine as long as the ActionResult requiring Authorization is in the same section (the root 'area'). But say I have an Area...

Areas

  • Profile

So that would be a URL of /Profile/Home/ for the Index() ActionResult. I get an error...

Server Error in '/' Application.

The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Account/Login

Notice

This is not the path I have specified in my Web.config. So in the 'root' area controllers, it obeys the Web.config, but in the other Areas, it seems to ignore it and go with ASP.NET defaults.

Any thoughts?

I have spoken with the Hosting company, and they swear to me that the default Web.config on their end isn't modified, and there is no reason why I can't modify my own Web.config - but this only happens when I upload it to their servers. They refuse to assist me any further.

Do I have to do anything special for IIS7 or IIS7.5 to make this redirect work?

1
  • can you post what your routes look like?
    – hunter
    Dec 22, 2010 at 13:13

2 Answers 2

3

The following worked for me.

Change the Startup.Auth file in the App_Start directory. That file also contains a redirect to Account/Login

Startup.Auth file

2

Check the Web.Config files in the various areas. Be sure that they do NOT have an Authentication tag which would override the global Web.Config setting.

1
  • Yes, there was a duplicate somewhere by accident.
    – Ciel
    Dec 22, 2010 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.