How to set hostname in publication Asp net core 3.1 selfHosted

Asked

Viewed 59 times

0

I have a working project which the publication preference is in the format of publish to self hosted folder (selfhosted) (without using IIS). Reason for this: the goal is to decrease the work/knowledge of who will deploy, not needing to configure anything but copy, paste and run .exe. In this format, the publication generates in a Publish folder all the necessary files and one . exe, which when running raises the service. as shown in the following image:

Funcionamento esperado

Note: On the same server has IIS hosting two other sites made with Asp . net framework, even already using port 80 in both, but each with its different hostname. example: one is demo.nossosite.com.br on *:80 and the other is dev.nossosite.com.br on *:80.

It is important to note that for the operation of the new site (done in Asp .net core selfhosted) according to the previous image, it was only possible after stopping the two sites that used port 80. With the two sites working in an attempt to lift the new, an error occurs as per image: Erro

"crit: Microsoft.AspNetCore.Server.Kestrel[0] Unable to start Kestrel. System.Net.Sockets.Socketexception (10013): An attempt to access a socket in a way that is prohibited by access permissions."

In IIS, in the list of Sites, right click on any site, option "Associations", it is possible to make the configuration of which hostname along with the port pointed to that particular site selected.

I believe the problem I am facing is related to this lack of hostname configuration. Means I’ve tried before:

  • In launchSettings.json attributo applicationUrl where they had localhost quotes I switched to.nossosite.com.br
  • In appsettings.json attributo Allowedhosts where I had only one "*" I switched to "sitenovo.nossosite.com.br"
  • In Program.Cs in the Createhostbuilder method using . Useurls() stating the corresponding urls.

It seems that no one has the same effect as the configuration of Associations made in the IIS cited above. Before you tell me: just change the door to another door, for our scenario is unviable, we need it to be at door 80. Does anyone know how to solve this/has already experienced this problem of needing to keep websites hosted on IIS and at the same time self hosted?

  • Are you sure the two apps weren’t on different routes? For example, "http://dev.nossosite.com.br:80/app1/xxxx" and "http://dev.nossosite.com.br:80/app2/xxxx"?

1 answer

0

You can even do the Binding of a dns host name for its application, for example:

var host = new WebHostBuilder()
.UseKestrel()
.UseUrls("http://dev.nossosite.com.br:80", "http://localhost:80")

However, you will not be able to put more than one application on the same door, on the same machine.

This is possible in the IIS because it manages the requests and makes the correct redirects, already an application self Hosted is not covers to do this, because if there are two app wanting to do bind from the same door, who will manage this?

It has to be "someone" beyond the two (or more) apps to do this, here comes the IIS or another web server.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.