When running the app locally, all routing works fine. But when publishing to Azure, only the non-Area controllers work (such as "Home" and "Account"), the area-routes return 404.
Startup.cs has the following:
routes.MapRoute("areaRoute", "{area:exists}/{controller}/{action=Index}/{id?}");
project.json has dependencies (amongst others):
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
}
and frameworks:
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
and publishOptions:
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
There's an issue with the globbing pattern that is being tracked via https://github.com/dotnet/cli/issues/3795. Listing individual areas in the publish/include
section could be used as a workaround. For instance,
"include": [
"wwwroot",
"Views",
"Areas/Area1/Views",
"Areas/Area2/Views",
"appsettings.json",
"web.config"
]
The problem was fixed for me by checking all ".cshtml" files have "Build Action: Content" set in the properties window. For some reason, my Index.cshtml was set to "Build Action: None".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With