Sunday, 2 June 2019

How To Deploy Angular And .NET Core Web API On IIS?

We have two web sites on IIS for both angular_client and web_api, the hosting bundle is installed and the permission to users such as IUSR, Network, Network Service and Everyone, is already granted.

The navigation to each site seperately works, i.e in the API, the call http://localhost:51975/api/user, results in list of all users.

The problem is that Angular login page fails to communicate with the API to authenticate users:

OPTIONS http://localhost:51975/api/user/authenticate net::ERR_CONNECTION_REFUSED

I tried to modify the IP associated with the API to a static one, i.e 10.1.x.y and then tell angular to call http://10.1.x.y:51975/api/user/authenticate instead.

In the API I enabled sending the log to browser and also to logs folder, the only log it shows is:

Hosting environment: Production
Content root path: C:\inetpub\wwwroot\api
Now listening on: http://127.0.0.1:39834
Application started. Press Ctrl+C to shut down.
Application is shutting down...

Why it is listening on other port rather than the associated one 51975?

Why the connection is refused from the Angular to the API?

Why the application is shutting down?

Is this the right approach to do this?

UPDATE 1

On the server ONLY, the application works fine, with the following configurations:

  1. Angular is on 10.x.y.z:4200,

  2. API 10.x.y.z:51975,

  3. CORS is fixed properly.

The problem is that when I try to use the public ip or my host name, I still can access only the angular but not the Web API, I tried to assigne the host name for the api, and it is not working yet!

UPDATE 2

I have also allowed both of the ports 4200 and 51975 on my host name domain.

Thank you



from How To Deploy Angular And .NET Core Web API On IIS?

No comments:

Post a Comment