我正在运行带有IIS 7.5的ASP.NET 5(Core)。我已经安装了httpPlatformHandler并将站点的物理路径(在IIS中)设置为来自Visual Studio 2015发布的wwwroot文件夹。但是,我得到的仅是空白的不断加载页面。我很确定我已经正确地连接所有内容。如果我取消注释Configure方法中的app.Run语句并注释掉app.UseIISPlatformHandler、app.UseDefaultFiles、app.UseStaticFiles和app.UseMVC,则可以正常加载。以下是我的代码。我现在不知道该怎么办。有什么建议吗?如果需要其他代码片段,请告诉我。
Startup.cs(Configure方法)
Startup.cs(Configure方法)
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未找到。还有其他建议吗?
附上完整的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);