Asp.net core 在IIS后面的Azure WebApps上部署ASP.NET 5
我在获取向Azure WebApps上托管的ASP.NET 5应用程序发送请求的客户端的IP地址时遇到问题 我的项目使用ASP.NET 5+MVC6,并在完整的CLR运行时(而不是CORECRL)上运行。我在网上搜索过答案,但没有找到任何解决办法 使用来自 我试过:Asp.net core 在IIS后面的Azure WebApps上部署ASP.NET 5,asp.net-core,azure-web-app-service,asp.net-core-mvc,dnx,kestrel-http-server,Asp.net Core,Azure Web App Service,Asp.net Core Mvc,Dnx,Kestrel Http Server,我在获取向Azure WebApps上托管的ASP.NET 5应用程序发送请求的客户端的IP地址时遇到问题 我的项目使用ASP.NET 5+MVC6,并在完整的CLR运行时(而不是CORECRL)上运行。我在网上搜索过答案,但没有找到任何解决办法 使用来自 我试过: HttpContext.Connection.RemoteIpAddress 但是HttpContext.Connection的属性要么为false,要么为null,所以这里没有运气 我注意到以下几点:当我使用IIS Expres
HttpContext.Connection.RemoteIpAddress
但是HttpContext.Connection的属性要么为false,要么为null,所以这里没有运气
我注意到以下几点:当我使用IIS Express通过Visual Studio运行我的应用程序时,Connection.RemoteIpAddress
的IP可用。
当我通过命令行运行dnx web时,属性为null。azure似乎在dnx上运行我的应用程序,而不是IIS
所以我的问题是:
如何配置project并将其部署到Azure WebApps,使其在IIS之后运行,从而运行HttpContext。连接将填充其值?
我当前的配置(project.json摘录):
以及Startup.cs的配置方法
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseIISPlatformHandler();
//rest of the method...
}
Azure Web应用程序始终使用IIS 但是,对于ASP.NET 5代码,IIS配置为使用HttpPlatformHandler将请求重定向到ASP.NET 5 web服务器Kestrel。 这是从ASP.NET Beta 8运行ASP.NET 5应用程序的方法。 通过打开web.config文件,您将看到该配置 参考资料:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseIISPlatformHandler();
//rest of the method...
}