user2309944
user2309944

Reputation:

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:

enter image description here

Upvotes: 1

Views: 871

Answers (5)

Baratali Qadamalizada
Baratali Qadamalizada

Reputation: 88

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"

Upvotes: 1

timkly
timkly

Reputation: 793

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.

Upvotes: 1

Husni Salax
Husni Salax

Reputation: 2020

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;)

Upvotes: 1

Jasser
Jasser

Reputation: 1

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

Upvotes: 1

Give your virtual directory root folder all rights (read/write)

Upvotes: 1

Related Questions