I still feel like having two separate applications set up would be cleaner and easier to manage. You can always separate out anything you need (for instance, in your case, you can have different authentications set up) and you can share any kind of code between them, including controllers, services, and middlewares.
However, if you want to have it in the same application, you could try playing around with middlewares. From what I have seen, the MVC middleware only gives you access to the routing mainly, not ports. You can, however, add a middleware before UseMvc
to reset a path. Something like this:
app.Use(async (context, next) => {
if (context.Connection.LocalPort == 80)
context.Request.Path = "/ports/80" + context.Request.Path.Value;
await next();
});
You can look into areas to organize your controllers for routing after doing this. https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/areas. You will have to make sure all ports have this mapping to ensure that end users can't hardcode such paths.