I have an ASP.NET Core app which is running fine locally.
However, when I publish (Web Deploy) the site to Azure, I get a 403:
The problem came from insufficient IIS integration/configuration.
I had to add the following to project.json
:
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
}
I also added a postPublish script for IIS publishing:
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
I also added the Microsoft.AspNetCore.Server.IISIntegration NuGet package:
"dependencies": {
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0"
}
This created a web.config file, which I had to modify as:
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\My.Web.App.dll" arguments="" forwardWindowsAuthToken="false" stdoutLogEnabled="true" stdoutLogFile="\\?\%home%\LogFiles\stdout" />
</system.webServer>
</configuration>
Finally I added UseIISIntegration to my WebHostBuilder:
public static void Main(string[] args)
{
new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.UseIISIntegration() // This was missing
.Build()
.Run();
}
A standard Publish (Web Deploy) from Visual Studio and the website started just fine on Azure (although in my case I also had to add a prepublish script for some Gulp tasks).