简体   繁体   中英

How to publish MVC application with form authentication on IIS

I have an ASP.NET MVC application using Form Authentication , with the following configuration in the web.config file:

<system.webServer>
    <modules>
        <remove name="FormsAuthentication" />
    </modules>
</system.webServer>

I can successfully publish the application on IIS from within the Visual Studio. But when I browse it in the browser, I get a 500 Internal Server Error with the following description:

在此处输入图片说明

Check if your IIS components like ASP.NET 4.6, etc are installed. Sometimes this problem occurs in the lake of IIS main components. You can check this in "Turn Windows features on or off"

授予您的虚拟目录根文件夹所有权限 (读/写)

make sure the app pool is using the right version of the .net. it is by default pointing to .net 2.0.

Here we go:

Did you register .NET with IIS? If not run the following commands:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i

You need to do this from an elevated command prompt (cmd) (...run as admin)

Than you have to create this row in your config file:

</system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />

Follow this tutorial: enter link description here

Hope it helps;)

The error message is telling you that this section is locked, generally in the applicationHost.config file. So you need to unlock it before you can modify it in the web.config file. See this for more info. Optionally run this command to unlock the section.

%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/modules

I would avoid reinstalling .Net and changing permissions until you have tried this.

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