Reputation: 95
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.
Upvotes: 0
Views: 747
Reputation: 1001
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!
Upvotes: 1