开发者

ASP.NET MVC, Forms Authentication Redirect from Areas

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/L开发者_Python百科ogin

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?


The following worked for me.

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

ASP.NET MVC, Forms Authentication Redirect from Areas


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜