简答
但是当我发布,并尝试打开,我看到的只是空白页面的不停加载。
发生这种情况时,我们的应用程序无法发布运行时(dnx.exe
)与应用程序。
讨论
有几种方法来发布ASP.NET核心RC1应用到Azure的Web应用程序。这些包括使用Git进行连续部署以及使用Visual Studio进行发布。发布您的存储库的内容以获得特定帮助。
该示例是通过GitHub连续部署部署到Azure Web App的ASP.NET Core rc1应用程序。这些是重要的文件。
app/
wwwroot/
web.config
project.json
startup.cs
.deployment <-- optional: if your app is not in the repo root
global.json <-- optional: if you need dnxcore50 support
应用程序/ wwwroot文件/ web.config中
添加HttpPlatformHandler
。将其配置为将所有请求转发给DNX进程。换句话说,告诉Azure Web应用程序使用DNX。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler"
path="*" verb="*"
modules="httpPlatformHandler"
resourceType="Unspecified"/>
</handlers>
<httpPlatform
processPath="%DNX_PATH%"
arguments="%DNX_ARGS%"
stdoutLogEnabled="false"
startupTimeLimit="3600"/>
</system.webServer>
</configuration>
应用程序/ project.json
包括红隼服务器上的依赖。设置将启动Kestrel的web
命令。使用dnx451
作为目标框架。请参阅下面的目标dnxCore50
的额外工作。
{
"dependencies": {
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": { }
}
}
应用程序/ Startup.cs
附上Configure
方法。这增加了一个非常简单的响应处理程序。
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
namespace WebNotWar
{
public class Startup
{
public void Configure(IApplicationBuilder app)
{
app.Run(async (context) =>
{
await context.Response.WriteAsync(
"Hello from a minimal ASP.NET Core rc1 Web App.");
});
}
}
}
。部署(可选)
如果您的应用程序不在存储库根目录中,请告诉Azure Web应用程序哪个目录包含该应用程序。
[config]
project = app/
global.json(可选)
如果你想针对.NET的核心,告诉Azure中,我们要瞄准它。添加此文件后,我们可以用我们的project.json替换(或补充)dnx451
条目与dnxCore50
。
{
"sdk": {
"version": "1.0.0-rc1-update1",
"runtime": "coreclr",
"architecture": "x64"
}
}
请发布您的存储库的关键内容(例如project.json,startup.cs,web.config ...)然后我们可以提供特定的帮助。 –