IIS Confusion

Brad White 41 Reputation points
2021-07-07T23:18:56.753+00:00

I have an existing website running, let's call it Portal, at http://localhost:80.
Now I need to add a related API so that a webhook can post data here.

I added the new web api, put it on port 8000, created a new AppPool.
http://localhost:8000

For debugging, I have Portal, the original website, turned off in IIS.

When I go to http://localhost:8000/api/Values, I get errors in the Portal code, when it should be hitting the Values controller.
[NullReferenceException: Object reference not set to an instance of an object.]
Portal.Controllers.BaseController.GetDefaultContext() in {path}\Portal\Controllers\BaseController.cs:39

and

[InvalidOperationException: An error occurred when trying to create a controller of type 'Portal.Controllers.APIController'. Make sure that the controller has a parameterless public constructor.]

This works fine on my local machine, just not on the server.
I can't see how it could get to the Portal code or even know about Portal controllers.

Any thoughts?

Internet Information Services
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,560 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,490 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce Barker 801 Reputation points
    2021-07-08T14:35:08.267+00:00

    Your default site is bound to all ports, so localhost:8000 is going to the original site.

    In addition to the app pool you need to define a new site bound to port 8000. You will also need to limit the default site to port 80 instead of all ports.

    1 person found this answer helpful.
    0 comments No comments

  2. Brad White 41 Reputation points
    2021-07-09T01:06:05.517+00:00

    @Bruce Barker That is certainly what it acts like. 8: -)

    Turns out it was a deployment failure. My script failed in changing directory when I thought it did, so it was copying the wrong files.
    When I added some logging messages and none of my changes were showing up, I got suspicious.

    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.