【发布时间】:2016-04-05 17:50:41
【问题描述】:
我正在使用 IIS 7.5 运行 ASP.NET 5 (Core)。我已经安装了 httpPlatformHandler 并将站点的物理路径(在 IIS 中)设置为我从 Visual Studio 2015 发布的 wwwroot 文件夹。我得到的只是空白的连续加载页面。我很确定我已经正确连接了所有东西。此外,如果我从 Configure 方法中取消注释掉 app.Run 语句并注释掉 app.UseIISPlatformHandler、app.UseDefaultFiles、app.UseStaticFiles 和 app.UseMVC,它会正常加载。
我的代码如下。我不知道此时还能做什么。有什么建议?如果需要任何其他代码 sn-ps,请告诉我。
Startup.cs(配置方法)
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
app.UseIISPlatformHandler();
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMvc();
//app.Run(async (context) =>
//{
// var greeting = greeter.GetGreeting();
// await context.Response.WriteAsync(greeting);
//});
}
web.config
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600" forwardWindowsAuthToken="true" />
新编辑。我已将文件夹结构更新为 MVC(使用控制器、视图等),并且稍微更改了 Configure 方法。现在它加载一个空白屏幕,控制台正在记录 404 not found。还有什么建议吗?
添加我的完整 Startup.cs:
public IConfiguration Configuration { get; set; }
public static string ConnectionString { get; set; }
public Startup()
{
var builder = new ConfigurationBuilder()
.AddJsonFile("appsetting.json")
.AddEnvironmentVariables();
Configuration = builder.Build();
ConnectionString = Configuration.GetSection("connString").Value;
}
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
app.UseIISPlatformHandler();
//app.UseDefaultFiles();
app.UseFileServer(true);
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}");
});
}
// Entry point for the application.
public static void Main(string[] args) => WebApplication.Run<Startup>(args);
【问题讨论】:
-
您是否收到任何错误消息?您在事件查看器中看到什么了吗?
-
否定。我得到空白的连续加载页面。完全没有错误
-
以前报错,后来下载了httpplatformhandler,现在就这样了。
-
什么版本的平台处理程序?为此,您需要 1.2 版(或更高版本)。
-
我下载了 v1.2 但是我要去哪里仔细检查版本?
标签: c# asp.net asp.net-mvc iis