[{"data":1,"prerenderedAt":130},["ShallowReactive",2],{"/2025/12/01-configure-port-on-aspnet-webapi":3},{"id":4,"title":5,"body":6,"date":121,"description":76,"extension":122,"meta":123,"navigation":124,"path":125,"robots":126,"seo":127,"stem":128,"__hash__":129},"posts/2025/12/01 configure-port-on-aspnet-webapi.md","01 Configure Port On Aspnet Webapi",{"type":7,"value":8,"toc":118},"minimark",[9,18,21,25,27,44,46,54,56,64,77,79,82,84,92,94,108,110,113,115],[10,11,13],"post-title",{":date":12},"date",[14,15,17],"h1",{"id":16},"configure-port-on-aspnet-web-api","Configure Port on ASP.NET Web API",[19,20],"br",{},[22,23,24],"p",{},"I have a ASP.NET Web API using Minimal that's integrated with ASP.NET Aspire. It's great that a single command will start the application along with the supporting resources, but when I need to modify the code, I have to first stop it in Aspire, build, and then restart it in Aspire. It is a hassle compare to just click \"Start Debugging\" in Visual Studio.",[19,26],{},[22,28,29,30,38,39,43],{},"So, I did just that, stop it in ASP.NET Aspire and start it through Visual Studio. But I noticed that the port launched through ASP.NET Aspire and Visual Studio are different although both are supposed to use ",[31,32,37],"code",{"className":33},[34,35,36],"bg-gray-200","p-2","rounded","launchSettings.json",". Through Visual Studio, it defaults to ",[31,40,42],{"className":41},[34,35,36],"http://localhost:5000"," no matter http or https profiles used to launch it, while ASP.NET Aspire use ports specified in launchSettings.json. That prompts me to find a way to match the port so it doesn't change when I launch from either Aspire or Visual Studio.",[19,45],{},[22,47,48,49,53],{},"Further investigation, launchSettings.json is meant to be used by Visual Studio. So the profiles are visible in Visual Studio, but apparently the applicationUrl field is not picked up in my case although it is running using Kestrel indicated by ",[31,50,52],{"className":51},[34,35,36],"\"commandName\": \"Project\"",". In this case, my application is running .NET 10 and I use Visual Studio 2026 community.",[19,55],{},[22,57,58,59,63],{},"Visual Studio has a built-in Debug UI under ",[31,60,62],{"className":61},[34,35,36],"\u003Cyour-project> > Right click > Properties > Debug > General > Open debug launch profiles UI",". If I provide the following command line arguments, then it will use the specified port and add that argument to launchSettings.json.",[65,66,67],"code-block",{},[68,69,74],"pre",{"className":70,"code":72,"language":73},[71],"language-text","--urls http://localhost:5123\n","text",[31,75,72],{"__ignoreMap":76},"",[19,78],{},[22,80,81],{},"As of this point, I can't find a way to get Visual Studio to use the applicationUrl in the launchSettings.json, so I temporarily use the command line arguments.",[19,83],{},[22,85,86,87,91],{},"Other things that I learned is ",[31,88,90],{"className":89},[34,35,36],"WebApplication.CreateSlimBuilder()"," will only support http as https termination is usually done on the ingress which I can relate since I built a whole environment from scratch in AWS before.",[19,93],{},[22,95,96,97],{},"For more information: ",[98,99,102],"span",{"className":100},[101],"text-blue-600",[103,104,105],"a",{"href":105,"rel":106},"https://learn.microsoft.com/en-us/aspnet/core/fundamentals/native-aot?view=aspnetcore-10.0#the-web-api-native-aot-template",[107],"nofollow",[19,109],{},[22,111,112],{},"Other things to mention is since we are planning to use the same port, we need to remove the code to launch the application in Aspire to prevent port conflict.",[19,114],{},[22,116,117],{},"In my case, my Aspire solution also include the application projects, so Aspire needs to run first so it can copy the project files before running the application through different instance of Visual Studio.",{"title":76,"searchDepth":119,"depth":119,"links":120},2,[],"2025-12-01T00:00:00.000Z","md",{},true,"/2025/12/01-configure-port-on-aspnet-webapi",null,{"title":5,"description":76},"2025/12/01 configure-port-on-aspnet-webapi","WSuWze41kYix4suevS-Rziw_31YN91m1Lz_GLZzogZE",1785167452357]