我有一个asp.net核心应用程序,在本地运行良好。
但是,当我将网站发布(web部署)到azure时,我得到一个403: 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" });
});
web部署到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/"
}
}
编辑:
首先,我错过了 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 express上运行它(虽然我猜它是iis fronting kestrel?) 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.
但不确定这如何适用于azure?
1条答案
按热度按时间sbtkgmzw1#
问题来自iis集成/配置不足。
我不得不补充以下内容
project.json
:我还为iis发布添加了发布后脚本:
我还添加了microsoft.aspnetcore.server.iisintegration nuget包:
这创建了一个web.config文件,我必须修改为:
最后,我将useiisintegration添加到我的webhostbuilder中:
一个来自visualstudio和网站的标准发布(webdeploy)在azure上启动得很好(尽管在我的例子中,我还必须为一些gulp任务添加一个预发布脚本)。