IIS 8中的ASP.NET 5主机应用程序,带有https绑定

时间:2016-01-19 21:54:55

标签: asp.net asp.net-mvc iis asp.net-core-mvc

早些时候我遇到了在IIS中托管ASP.NET 5应用程序的问题,现在我可以通过http托管它了。这是我的old post,其中包含详细信息。

在过去的几天里,我一直在尝试通过端口443为我的应用程序启用https。在launchSetting.json文件中,我使用有效证书将iisexpress设置更新为"applicationUrl": "https://servername:443/"。但是当我在浏览器中浏览应用程序时,仍然会收到404错误。

这是我的launchSettings.json文件:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "https://servername:443/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "Hosting:Environment": "Development"
      }
    },
    "web": {
      "commandName": "web",
      "environmentVariables": {
        "Hosting:Environment": "Development"
      }
    }
  }
}

这是我的project.json文件:

"dependencies": {
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.Core": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "Microsoft.Net.Http.Server": "1.0.0-beta5",
    "dnx-clr-win-x64": "1.0.0-rc1-update1",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel"
  }

Startup.cs文件:

public class Startup
    {
        // 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()              // Add MVC Dependency.
                .AddJsonOptions(
                    opt =>
                    {
                        opt.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); // Api convert all property names to CamelCase.
                    }
                );
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, ILoggerFactory LoggerFactory)
        {
            LoggerFactory.AddDebug(LogLevel.Warning);
            app.UseIISPlatformHandler();
            app.UseStaticFiles();

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", Action = "Index" }
                    );
            }); // Use MVC from Dependency.
        }

        // Entry point for the application.
        public static void Main(string[] args) => WebApplication.Run<Startup>(args);
    }

我不确定在应用程序中启用https是否正确,但是使用有效证书正确配置了IIS绑定。所以我不确定为什么它仍然会抛出404错误。

社区的任何帮助都非常感谢。 :)

0 个答案:

没有答案