0

I've got a webapi that runs in production on a Virtual Directory on ISS, end result is something like api.companyname.com/APINAME/

Now I need to be able to locally test the API using either dotnet run or IIS Express with a baseUrl such as the above, the end result would be something like localhost:5555/APINAME/.

My problem is that I can't change anything in code to have it work and I can't find anything in the web as to where I can go to configure this. I've tried changing the LaunchSettings.json file as well.

1
  • 1
    Not entirely clear what you're asking, but you're LaunchSettings.json should contain the location that you web service is going to be running at. Your AppSettings.json should specify any addresses at which you call the web service. That said, if you can't access the code and the code isn't looking in AppSettings.json, there's not much you can do. Commented Mar 22, 2020 at 13:30

1 Answer 1

1

There are two different things you are trying to achieve.

To (re)define the listening endpoint(s), you can use the --urls parameter of dotnet the following way:

dotnet <yourdll.dll> --urls "http://*:5000"

You can also provide more than one endpoint (i.e. https, ipv6,...)

Try it out now.

My guess it, that this is all you need to do, and the App already has the path configured. If not, read on.

The other thing is the path base. That ("/myapp/") cannot be configured this way. To do that, you need to alter the source code. Best practice is to configure your AppBuilder like that:

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        app.UsePathBase(...);
        ....

If you cannot edit the source code, you could wrap your own application around the dll. But thats going to far to be answered here.

Please accept as answer when it worked, thank you.

Have Fun!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.