我有一個本地運行良好的ASP.NET Core應用程序。ASP.NET Core應用程序在發佈到Azure後不工作
然而,當我發佈(網絡部署)現場天青,我得到一個:You do not have permission to view this directory or page
。
我有一個默認的控制器和Startup.cs定義的路由:網在部署到Azure的
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
});
的文件夾結構是這樣的:
|_ 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/"
}
}
編輯:
原因之一,我錯過了Microsoft.AspNetCore.Server.IISIntegration
NuGet包。當我添加它時,我還在網站根目錄中找到了一個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快遞本地運行(雖然我想這是IIS對開紅隼?),但如果公佈天青我得到錯誤: HTTP Error 502.5 - Process Failure
事件日誌在Azure中指出: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.
不知道如何適用於天青有關係嗎?
你使用的是什麼版本的dotnet?另外,你有什麼包在project.json? –
我已經添加了我的project.json文件,運行Core 1.0 RTM。 –
@TedNyberg可能由於缺少'publishOptions'中的web.config而發生問題。試着像'[「wwwroot」,「Views」,「appsettings.json」,「appsettings。*。json」,「web.config」]一樣添加web.config。 –