繁体   English   中英

为什么我的ASP.NET 5应用程序不能在IIS 7.5上运行?

[英]Why does my ASP.NET 5 Application Not Run On IIS 7.5?

我正在使用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(配置方法)

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);

您是否查看过IIS日志以查看该请求是否正在向IIS发送?

您还可以尝试在Startup类的Configure()方法中定义的每个中间件模块之间放置一个简单的中间件模块。 您的中间件可以向Windows事件日志写入一条消息,说明它在Http管道中的位置以及响应正文的内容。 有点像放入警报来调试Javascript。 这至少会让你知道它挂起或清除响应主体的位置。

我在github上发布了一个非常容易理解的演示,演示了如何通过三个简单的步骤创建中间件。 点击这里进入该演示。

更新:尝试将Configure()方法更改为下面的代码(如果我的设置不正确,请放入您自己的路径)。

app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());
app.UseStaticFiles();

app.UseMvc(routes =>
{
    routes.MapRoute(
        name: "default",
        template: "{controller=Home}/{action=Index}/{id?}");
});

抱歉延迟,我没​​有打开电子邮件提醒。 这是我的web.config

<configuration>
  <system.webServer>
    <handlers>
      <add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>
    <httpPlatform processPath="..\approot\web.cmd" arguments="" stdoutLogEnabled="true" stdoutLogFile="..\logs\stdout.log" startupTimeLimit="3600"></httpPlatform>
  </system.webServer>
</configuration>

它可能是您的应用程序池运行的标识。 身份用户必须在其PATH环境变量中具有多个dnx路径。 因此,最简单的方法是将用户名设置为应用程序池标识,因为您应该在PATH环境变量中包含这些路径。

编辑:当我们设置QA机器时,我们必须创建三个系统环境变量并将它们指向安装RC1的用户配置文件。 那些是:

DNX_HOME - C:\Users\<username>\.dnx

DNX_PACKAGES - C:\Users\<username>\.dnx\packages

DNX_PATH - C:\Users\<username>\.dnx\bin\dnvm.cmd

应用程序池标识用户显然需要访问这些路径。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM