asp.net-mvc - 从 IP 地址远程访问本地 ASP.NET Core 应用程序?
问题描述
我想从远程计算机或移动设备(调用)调试我的 asp.net 核心应用程序?请帮我。在标准 .net 中,.vs\config\applicationhost.config
在更改<binding protocol="http" bindingInformation="*:21918:localhost" />
其<binding protocol="http" bindingInformation="*:21918:*" />
工作时添加此代码。
<site name="project" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="F:\users\Api" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:21918:*" />
</bindings>
</site>
解决方案
您可以使用此方法:
在您的项目中打开 Program.cs:
var configuration = new ConfigurationBuilder()
.AddCommandLine(args)
.Build();
var hostUrl = configuration["hosturl"]; // add this line
if (string.IsNullOrEmpty(hostUrl)) // add this line
hostUrl = "http://0.0.0.0:5001"; // add this line
var host = new WebHostBuilder()
.UseKestrel()
.UseUrls(hostUrl) // // add this line
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseConfiguration(configuration)
.Build();
host.Run();
推荐阅读
- javascript - Django 动态表单集:正确使用内联表单集?
- mysql - 为什么执行 count() 会返回带有回溯的 PhpMyAdmin 错误
- vue.js - 导航选项卡重新加载页面
- vue.js - 在自定义指令中模拟 v-if 指令
- c++ - 特征:如何将“大于”(在 ArrayXf 上)的结果转换为特征向量
- spring - java.lang.IllegalArgumentException:在方法名称中发现无效字符。HTTP 方法名称必须是微服务中的标记
- ios - iOS中的堆栈视图问题
- java - 如何修复此异常不匹配错误?
- r - ggplot 根据值以不正确的顺序渲染图
- java - NotifyAll/SignalAll 使线程停止正常工作