❔ hosting an asp.net core api in a winform app.
How can I host an asp.net core api in a winform app, where the api starts and stops based on user gui input and where the api console is displayed on the gui?
32 Replies
the same way you host an ASP.NET Core API in any other app
except you move the application host into your GUI logic instead of Main() and you redirect the console
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
agreed
the way you suggest that makes it sound really easy, I would really appreciate some help at your earliest convenience.
if you have a question, ask it
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I mean, you definitely don't need to make separate projects
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
if i create two separate projects within one solution, would i be able to export the whole solution as one executable?
yes
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
definitely
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
would you be willing to spend around 10 minutes helping me in a vc? i already have the winform app running
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ok, ill try to follow the steps you've mentioned
an ASP.NET Core app is pretty trivial to bootstrap
i dont understand what you mean.
by trivial to bootstrap
split that up across your start and stop methods in your GUI and you're done
I mean the code I JUST gave you
im currently setting up the api project within my solution
once im set up, then im going to try what you suggested
by the way, do i need to make a desktop project reference the api project?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
i managed to create both projects in one solution, now correct me if im wrong:
what i need to do is move the api logic into the winform app?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
i did exactly what you told me not to.. (because i dont know how to implement what you've suggested)
what i tried:
1 solution , 2 projects :
- building the api in the winform program.cs on a seperate thread..
=>(feels wonkey)
- creating a new process that references the api executable..
=>(eventually i might not have access to the api exe which would ruin this whole setup.)
what am going to try next:
creating the api within the winform app, so that i could have access to the whole api in order to manage it. (tips would be appreciated)
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ok, what next? how can i manage the api from the winform gui? (start api, stop api, restart, log, etc....)
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
am not familiar, i recently jumped on the core train, i been using .net framework for a while.
and this spicific usecase it new territory for me.
just finished testing that,
api runs, but the gui freezes.
i tried both runasync, and startasync
both freeze the desktop app
i got pretty close with creating a separate process.. i might expore a bit more towards that
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
you're right, i wasn't (i added the async before void funcname), now its working perfectly
Thanks guys!!
what about getting the logs from the api console?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.