У меня есть приложение ASP.NET Core, которое работает нормально локально.Приложение ASP.NET Core не работает после публикации в Azure
Однако, когда я опубликовать (Web Deploy) сайт в Azure, я получаю : You do not have permission to view this directory or page
.
У меня есть контроллер по умолчанию и маршрут, определенный в Startup.cs:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
});
Структура папки после того, как веб-развертывания на Azure выглядит следующим образом:
|_ 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?)
Любая идея о том, что я следует искать в project.json или портале Kudu, чтобы выяснить, что не так?
Мой project.json
файл:
{
"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:
С одной стороны, я пропускал NuGet пакет Microsoft.AspNetCore.Server.IISIntegration
. Когда я добавил его, я также получил файл web.config
в корне сайта (который я включил через project.json
).
Я также добавил .UseIISIntegration()
к моему WebHostBuilder
в Startup.cs:
public static void Main(string[] args)
{
new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.UseIISIntegration() // This was missing
.Build()
.Run();
}
теперь я могу запустить его на IIS Express локально (хотя я предполагаю, что это IIS противостоя Kestrel?), Но при публикации в лазури я получаю сообщение об ошибке: HTTP Error 502.5 - Process Failure
журнал событий в лазури гласит: Failed to start process with commandline '"%LAUNCHER_PATH%" %LAUNCHER_ARGS%', ErrorCode = '0x80070002'.
Согласно документации, шаг поиска неисправностей:
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.
Не уверен, как это относится к Azure, правда?
Какую версию dotnet вы используете? Кроме того, какие пакеты у вас есть в project.json? –
Я добавил файл project.json с RTM Core 1.0. –
@TedNyberg Вероятно, проблема возникает из-за отсутствия web.config в 'publishOptions'. Попробуйте добавить web.config, например '[" wwwroot "," Views "," appsettings.json "," appsettings. *. Json "," web.config "]'. –