greenoldman
greenoldman

Reputation: 21062

How to use solely base path address?

I have ASP.Net Core app which I would like to run in two instances. Currently I am testing one instance to sort out the base address problem.

In "Startup.Configure" I added as first line:

            app.UsePathBase("/cam1"); 

And it works, in sense, when I request something like "https://localhost:5011/cam1/proc/requests/about" it is correctly handled. The problem for me is that if I skip "cam1" part in the address it is handled "correctly" as well -- this is not my intention, I would like to solely use path base, and nothing else. And here it looks like two addressing are active -- one using path base I provided and the other one not using path base provided.

How to use solely provided base path, and nothing else? In this example anything not starting with "https://localhost:5011/cam1/" should not be picked up by the running instance at all.

How to achieve this?

Upvotes: 0

Views: 863

Answers (1)

Ruikai Feng
Ruikai Feng

Reputation: 11566

app.UsePathBase() just tell the your app "/caml" will also be ok, if you want to force the path contain "/caml",try add [Route("caml/[controller]/[action]")] on your controller enter image description here if you want set it globally,try to set it as below(.net 6):

app.MapControllerRoute(
    name: "default",
    pattern: "~/caml/{controller=Home}/{action=Index}/{id?}");

Upvotes: 1

Related Questions