外部.NET Core访问站点? [英] .NET Core Access Site Externally?

查看:196
本文介绍了外部.NET Core访问站点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS 2019中使用Kestrel在调试模式下启动.NET Core应用程序时,我只能以 https:// localhost:5001 的身份访问。当我尝试用计算机的fqdn替换localhost时,出现无法访问站点。因此实际上是计算机和域名,因此 https:// win7.int.com:5001 。我想要这样做,以便可以从其他计算机访问该站点。如果它不能以这种方式在我自己的计算机上运行,​​我怀疑它是否可以在另一台计算机上使用。现在理想情况下,我将在此主页下拥有多个应用程序(例如app1,app2等)。 URL将是 https:// win7.int.com/app1:5001 https:// win7.int.com/app2:5001

等等,等等。

When I start my .NET Core app in VS 2019 using Kestrel in debug mode I can only access as https:// localhost:5001. When I try to replace localhost with my fqdn of my computer I get "Site cannot be reached". So actually it would be the computer and domain name so https:// win7.int.com:5001. I want to do this so that I can access the site from a different machine. If it doesn't work on my own machine this way I doubt it would on another. Now ideally I would have several apps under this main page (like app1, app2, etc.). URLs would be https:// win7.int.com/app1:5001 and https:// win7.int.com/app2:5001 and so on and so forth.

对不起,我有grails背景,当应用程序在本地主机上启动时,我可以用计算机替换本地主机名称,并且有效。我需要做些什么才能使它在.NET Core中工作而不通过IIS?想要使用Kestrel。

Excuse me I have a grails background and when an app starts on localhost I can just replace localhost with my computer name and it works. What do I need to do to make this work in .NET Core without going through IIS? Want to use Kestrel.

推荐答案

默认情况下,Kestrel仅绑定到 http:// localhost:5000 https:// localhost:5001

By default Kestrel only binds to http://localhost:5000 and https://localhost:5001

如果要更改此设置,可以使用使用服务器应侦听请求的端口和协议配置IP地址或主机地址。 UseUrls 方法:

If you want to change this you can configure the IP addresses or host addresses with ports and protocols that the server should listen on for requests by using the UseUrls method:

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args).UseKestrel().UseUrls("http://*:5000;https://*:5001")
.UseStartup<Startup>();

这篇关于外部.NET Core访问站点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆