简体   繁体   中英

MVC Authentication not working in IIS (works in IIS Express)

I have created an MVC project with individual authentication and am using the default template. When I launch the application from within visual studios (IIS express) I am able to view all the public pages, register an account, and login. Everything works great.

However, When I publish the project and host it on a full IIS server (on Windows Server 2016) I can view all the public pages, but registering or trying to sign in yields the following generic error:

在此处输入图片说明

I am using the LocalDb for the project and I noticed that the windows Identity on the deployed applicaiotn is "NT AUTHORITY\\SYSTEM" while the IIS Express application's is USER-DESKTOP\\User. Is this error being caused by a permissions issue and if so how do you fix this?

Also, is it bad to use localDB for a deployed project? There will only be two users using the application and they are both trusted.

It is totally not good idea to use localDB for a deployed project,
it is meant for developer testing only.

when you start debugging in vs the localDB is started.

its better if you use SQL Express
https://go.microsoft.com/fwlink/?linkid=866658

Try to set your site application pool identity to the local system by following the below steps:

1)Open iis manager

2)Go to the application pool and select your application pool name.

3)Click on the advance setting.

4)There is a "Process Model" option, under which there is an "Identity" option. This is by default the application pool identity. Change it to Local System, and you're done.

在此处输入图片说明

Set “Load User Profile” to True.

在此处输入图片说明

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