[英]Is there way to create a true selfhosted .Net ( Core) wepApp without any proxy
I can in ASP.NET and .NET Core create a selfhosted web service (WCF,REST, based on Kastrel or Katana and so on). 我可以在ASP.NET和.NET Core中创建自托管的Web服务(WCF,REST,基于Kastrel或Katana等)。 But is there a way to create a full working web site, or SPA, may be based MVC ? 但是,有没有一种方法可以基于MVC创建一个可以正常运行的网站或SPA?
For example I can inside .NET Core Startup file add code: 例如,我可以在.NET Core启动文件中添加代码:
app.Run(async (context) =>
{
await context.Response.WriteAsync($"Hello World! {
//insert your web site here :-)
}");
});
- but I should to create all html, js and so on code by myself. -但我应该自己创建所有html,js等代码。 May be we have a better way ? 也许我们有更好的方法?
Of course I know that we have a big parts like ASP and so on - but we can't create selfhosted app, we need a web server - usually IIS ! 当然,我知道我们有很大一部分,例如ASP等,但是我们无法创建自托管应用,我们需要Web服务器-通常是IIS!
I guess you mean that your self-hosted web server of visual studio is not accessible from the outside? 我猜您的意思是无法从外部访问Visual Studio的自托管Web服务器?
Assuming that your port forwarding and firewall are correctly configured. 假设您的端口转发和防火墙已正确配置。 You need to change the bind address of your application: 您需要更改应用程序的绑定地址:
new WebHostBuilder()
.UseKestrel()
...
.UseUrls("http://*:80")
...;
This should never be used without reverse proxy. 没有反向代理,决不能使用此功能。
More info about why this should not be done without reverse proxy: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-2.0&tabs=aspnetcore2x 有关为何不使用反向代理不应执行此操作的更多信息: https : //docs.microsoft.com/zh-cn/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-2.0&tabs=aspnetcore2x
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.