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: You do not have permission to view this directory or page
.
I have a default controller and a route defined in Startup.cs:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
});
The folder structure after web deploy to Azure looks like:
|_ home
|_ site
|_ wwwroot (contains DLL's and files specified through 'publishOptions' in project.json)
|_ wwwroot (the contents of the 'wwwroot' folder I have in Visual Studio)
|_ Views (contains MVC views)
|_ refs (contains referenced DLLs, I think?)
Any idea of what I should look for in project.json or the Kudu portal to figure out what's wrong?
My project.json
file:
{
"title": "My Web App",
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true,
"preserveCompilationContext": true,
"compile": {
"exclude": [ "bin/**", "obj/**", "node_modules/" ]
}
},
"publishOptions": {
"include": [ "wwwroot", "Views", "appsettings.json", "appsettings.*.json" ]
},
"scripts": {
"prepublish": [ "jspm install", "gulp build" ]
},
"dependencies": {
"Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"System.IO.FileSystem": "4.0.1"
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0"
},
"imports": "dnxcore50"
}
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel --server.urls=http://*:8000/"
}
}
Edit:
For one, I was missing the Microsoft.AspNetCore.Server.IISIntegration
NuGet package. When I added it, I also got a web.config
file in the site root (which I included through project.json
).
I also added .UseIISIntegration()
to my WebHostBuilder
in Startup.cs:
public static void Main(string[] args)
{
new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.UseIISIntegration() // This was missing
.Build()
.Run();
}
I can now run it on IIS Express locally (although I guess it's IIS fronting Kestrel?), but when published to Azure I get error:
HTTP Error 502.5 - Process Failure
The event log in Azure states: Failed to start process with commandline '"%LAUNCHER_PATH%" %LAUNCHER_ARGS%', ErrorCode = '0x80070002'.
According to the documentation, the troubleshooting step is:
If the server does not have Internet access while installing the server hosting bundle, this exception will ensue when the installer is prevented from obtaining the Microsoft Visual C++ 2015 Redistributable (x64) packages online. You may obtain an installer for the packages from the Microsoft Download Center.
Not sure how this applies to Azure, though?
publishOptions
. Try to add web.config like ` [ "wwwroot", "Views", "appsettings.json", "appsettings.*.json", "web.config" ]`. – adem caglin