messing with Asp.Net in desktop

JohnH

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
1,754
Location
Norway
Programming Experience
10+
I have barely looked at ASP.Net for 15 years, only browsed through some articles to see what's going on. A couple of days ago I decided to give minimal Apis and hosted services with C# project "ASP.Net Core Web Api" a test. This was easy to get up and running from VS. Tried the different VS configurations for Kestrel and IIS Express, which worked out of the box. It was surprising that this project type was available with only the Desktop workload added in VS.

Then I was thinking about running a service or two at local machine and how I would do that, not a fan of having console windows lying around. Hiding console windows or tricking by changing to winexe and run hidden doesn't sound appealing either, so I thought spinning up IIS Express from command line would be easy - think again! I was actually able to do it eventually with much troubles and "hacking" config files and doing manual folder permissions, but I wonder why that is so incredibly difficult? It should be an easy peasy "Express" setup.

At the end I decided adding the full IIS feature to Windows was the way to go if I want to have ASP.Net "Core" services running at local machine (for release, not debugging). Since I haven't been using that either for decades there was something to learn there too, got into a few obstacles with publishing with Web Deploy (and Web Deploy packages), but got there eventually. Of course I throw myself head first into things, creating app pools and applications all over the place, deleting and renaming, moving folders - basically having tested most things that can go wrong and fixing them.

I was surprised that it was easy to create such services with VB.Net too, even though project templates for this doesn't even exist. (just creating a console app and modifying "Sdk.Web" in project file)

Well, maybe I will create something useful with this eventually.
 
If it is just for in-home use, and you are really just hosting Web APIs, while not run the Kestrel apps as Windows services?

Admittedly, I've not tried it myself. I have only run the Kestrel apps as console apps. It shouldn't be too difficult to add on the ServiceBase class and transplant the guts of the Program.cs over.

Yeah, IIS Express is anything but "express" for anyone wanting to run it standalone. I think it's only "express" for working with Visual Studio.
:)
 
I know of the run as Windows Service option, I was trying to avoid that. It is just adding a call to builder.Services.AddWindowsService.
 
Back
Top Bottom