我试图在Asp.net Vnext中获取远程IP地址。
在我的代码中添加此行后,页面在已发布的IIS中停止工作
服务器(不显示错误,只有白屏):
var remoteIpAddress = HttpContext.Features.Get<IHttpConnectionFeature>()?.RemoteIpAddress;
当我在本地IIS-Express中检查结果时,它给了我:
这是我的project.json文件:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"DataAccessComponents": "1.0.0-*",
"Utility": "1.0.0-*",
"AdModels": "1.0.0-*",
"Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-rc1-final",
"Microsoft.Net.Http": "2.2.22",
"Newtonsoft.Json": "7.0.1",
"Microsoft.AspNet.Http.Abstractions": "1.0.0-rc1-final",
"System.Net.Http": "4.0.1-beta-23516",
"System.Net.Primitives": "4.0.11-beta-23516",
"System.Text.Encoding": "4.0.11-beta-23516",
"Microsoft.AspNet.WebApi.Client": "5.2.3",
"Microsoft.AspNet.Http.Extensions": "1.0.0-rc1-final",
"Microsoft.Dnx.Compilation.Abstractions": "1.0.0-rc1-final",
"Microsoft.AspNet.Http.Features": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System.Data": "4.0.0.0",
"System.Net.Http.WebRequest": "4.0.0.0",
"System.Web": "4.0.0.0"
}
}
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
此外我正在使用普通的IIS 8进行我的项目,我不会将此程序移植到另一个操作系统。
我应该更改项目json中的“Web”部分吗?喜欢添加iis还是什么?