How to host a Blazor Server application (localhost) and a Web API on a specified IP and Port?

Connor Peters 6 Reputation points
2023-01-12T14:37:25.9566667+00:00

Hello together,

I already installed Blazor Server app on a server (localhost:5001). Using localhost, it is not possible to acces my app from other servers in the network, which is a desired effect.

Now, I'd like to host a Web API (if possible, using the same Blazor Server app) on the specific IP address of the server and another port (let's say 5002). This API is supposed to deliver determined information from the Blazor server app.

Until now, I did not find an appropriate solution to host both apps and enable them to talk to each other. Is there any way to do this?

Developer technologies .NET Blazor
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-01-12T17:59:18.9733333+00:00

    there is no need for an additional ipaddress or port. just add webapi support to the blazor server app.

    as blazor server has a heavy load, you may want a separate site. a shared database may make sense.

    note: typically port 5001, etc are not open on the firewall, so can nt be access remotely. you would need to open the ports.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.