简体   繁体   中英

MVC 5 Authentication working in IIS Express but not in IIS

I have created an ASP .NET Web Application with MVC and Authentication as Individual User Accounts. I have populated the app with some controllers, actions and views. Some of them are [AllowAnonymous] and other [Authorize].

It works perfectly in IIS express. I can create multiple accounts. And logging. And see the pages I have access to.

When I deployed the app to my local IIS, the authentication stopped working. I can create accounts. But I cant log in. When I try to log in it only redirects me toward the home page and I cant see the pages. When i try to put fake access it detects that they are incorrect.

I tried to fiddle around in the IIS settings but a don't know what to do.

Please, help me.

在 IIS 中,为站点搜索身份验证功能并启用 Windows 身份验证并禁用匿名。

You need to keep your application to run anonymous authentication instead of windows authentication. Otherwise, you login page will get into infinite loop.

Besides,are you trying to connect a localdb with individual user account template in IIS? Have you tried to set applciation pool like this in applicationhost.config and remove "AttachDbFilename=....." from your web.config connection string? If I take the steps above, I can get both register and create work in my IIS.

 <add name="my app pool" autoStart="true">
                <processModel identityType="ApplicationPoolIdentity" setProfileEnvironment="true" />
            </add>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM