简体   繁体   中英

Asp.net core serving static files on different port than web api

I'm using asp.net core with kestrel and I want to serve static files along with hosting web api. Is there a way to serve static file on port different than the one for web api?

That would require basically running two web hosts simultaneously, since the port is inherently tied to webhost. It's possible you can do via IHostedService , but I don't think it would be trivial. Even if you got it working that way, I don't think it would likely do what you want, as the main host will still be involved, and the only rational reason I can imagine for this request is that you want to separate the load between two different host instances.

If that is indeed your goal, the only true way to do that is to use two totally separate ASP.NET Core apps (two different projects).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM