简体   繁体   English

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

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

I'm running ASP.NET 5 (Core) with IIS 7.5. 我正在使用IIS 7.5运行ASP.NET 5(Core)。 I've already installed httpPlatformHandler and set the physical path of the site (in IIS) to the wwwroot folder that I published from visual studio 2015. All I get is the blank continuous loading page. 我已经安装了httpPlatformHandler并将站点的物理路径(在IIS中)设置为我从visual studio 2015发布的wwwroot文件夹。我得到的只是空白的连续加载页面。 I am pretty sure I have everything wired up correctly. 我很确定我已经正确连接了所有内容。 Also, it loads up fine if I uncomment out the app.Run statement from within the Configure method and comment out the app.UseIISPlatformHandler, app.UseDefaultFiles, app.UseStaticFiles and app.UseMVC. 此外,如果我从Configure方法中取消注释app.Run语句并注释掉app.UseIISPlatformHandler,app.UseDefaultFiles,app.UseStaticFiles和app.UseMVC,它会加载正常。

My Code is below. 我的代码如下。 I don't know what else to do at this point. 我不知道此时还有什么可做的。 Any suggestions? 有什么建议? If any other code snippets are needed, let me know. 如果需要任何其他代码段,请告诉我。

Startup.cs (Configure method) 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 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" />

New Edit. 新编辑。 I've updated my folder structure to MVC (using Controllers, Views, etc) and I've changed the Configure method a bit. 我已经将我的文件夹结构更新为MVC(使用控制器,视图等),并且我已经更改了Configure方法。 Now it loads a blank screen and the console is logging a 404 not found. 现在它加载一个空白屏幕,控制台正在记录未找到的404。 Anymore suggestions? 还有什么建议吗?

Adding my full Startup.cs: 添加我的完整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);

Have you looked at the IIS logs to see if the request is even making to IIS? 您是否查看过IIS日志以查看该请求是否正在向IIS发送?

You can also try putting a simple middleware module inbetween each middleware module defined in the Configure() method of class Startup. 您还可以尝试在Startup类的Configure()方法中定义的每个中间件模块之间放置一个简单的中间件模块。 Your middleware can write a message to the Windows event log stating where it's at in the Http pipeline and the contents of the response body. 您的中间件可以向Windows事件日志写入一条消息,说明它在Http管道中的位置以及响应正文的内容。 Kind of like putting in alerts to debug Javascript. 有点像放入警报来调试Javascript。 That will at least let you know where it's hanging up or clearing the response body. 这至少会让你知道它挂起或清除响应主体的位置。

I posted a very easy to understand demo on github that demonstrates how to create middleware in three easy steps. 我在github上发布了一个非常容易理解的演示,演示了如何通过三个简单的步骤创建中间件。 Click here to go to that demo. 点击这里进入该演示。

UPDATE: Try changing your Configure() method to the code below (put in your own route if mine isn't correct for your setup). 更新:尝试将Configure()方法更改为下面的代码(如果我的设置不正确,请放入您自己的路径)。

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

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

Sorry for the delay, I didn't have email alerts turned on. 抱歉延迟,我没​​有打开电子邮件提醒。 Here's my web.config 这是我的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>

It could be the identity that your Application Pool is running under. 它可能是您的应用程序池运行的标识。 The identity user has to have a number of dnx paths in its PATH environment variable. 身份用户必须在其PATH环境变量中具有多个dnx路径。 So it's easiest just to set your username as the Application Pool identity because you should have those paths in your PATH environment variable. 因此,最简单的方法是将用户名设置为应用程序池标识,因为您应该在PATH环境变量中包含这些路径。

EDIT: When we setup our QA machine we had to create three System environment variables and point them to the user profile that installed RC1. 编辑:当我们设置QA机器时,我们必须创建三个系统环境变量并将它们指向安装RC1的用户配置文件。 Those are: 那些是:

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

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

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

And the Application Pool identity user obviously needs to have access to those paths. 应用程序池标识用户显然需要访问这些路径。

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

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