0

In a project im working on, we are upgrading our Episerver CMS website from CMS11 (.net framework) to Optimizely CMS12 (.Net core) for a customer.

To run IIS Express using CLI (to not have the need to run the application from VS/Rider) and start NPM develop, we have written this .bat script.

@ECHO OFF

ECHO starting site
start iisexpress /config:.vs\*PROJECT_NAME*\config\applicationhost.config /siteid:2
cd %~dp0\src\Site
start npm run develop

As a result of upgrading from framework to core, we are now configuring the project through appsettings.json instead of applicationhost.config (XML), where we define which site bindings to be launched from (siteid:2).

I've been looking for a way to do the same through bindings in .json, with no luck. Does anyone have any ideas for a solution?

  • The question is wrong to begin with. IIS is a service, not an application. That batch starts the IIS *service* with a different service config file, not even a web.config. Your ASP.NET site isn't using `applicationhost.config`, it uses `web.config`. IIS Express is *ONLY* meant for development though. In production, the IIS service starts and stops as a proper service. – Panagiotis Kanavos Jan 09 '23 at 09:29
  • 1
    Besides, ASP.NET Core applications can run standalone and don't need IIS. Whether they're hosted on IIS or not, `appsettings.json` is the equivalent of `web.config`, not `applicationhost.config`. The [Optimezely docs](https://docs.developers.optimizely.com/content-cloud/v12.0.0-content-cloud/docs/installing-optimizely-net-5) don't use IIS at all. – Panagiotis Kanavos Jan 09 '23 at 09:39
  • 1
    For SPAs, you don't need IIS. After all, IIS doesn't exist on Linux. The [Single Page Apps](https://learn.microsoft.com/en-us/aspnet/core/client-side/spa/react?view=aspnetcore-7.0&tabs=visual-studio) docs show how you can use Angular or React templates to create a React SPA with an ASP.NET Core backend and Node.js for development – Panagiotis Kanavos Jan 09 '23 at 09:40
  • @PanagiotisKanavos I may have phrased the question poorly, i'm sorry. When i'm stating I want to run the application, I do not mean just run the IIS service, but run the web application from inside Rider. This is a multisite application with numerous ports used, that's why we are currently, and still want to, use IIS to run the site for development. Its for dev only, the sites are hosted in Azure externally. Our site bindings are defined in `applicationhost.config`, not `web.config` as you are stating. But you're saying that IIS do not exist for Linux? Thats a bit worrying... – hattemaker Jan 09 '23 at 09:56
  • 1
    `IIS do not exist for Linux? Thats a bit worrying...` if there's any confusion on this you should start with the basics of ASP.NET Core *before* you try migrating anything. IIS is the Windows Web Server service. On Linux there are a lot of other web servers like NGINX. ASP.NET Core web apps can run standalone or they can be hosted internally in IIS or, on Linux, NGINX. They can also run *behind* another server that acts as a reverse proxy – Panagiotis Kanavos Jan 09 '23 at 10:02
  • You don't need to start the IIS Express service manually to debug an ASP.NET web app with Rider either. Rider itself will simply start it to debug any ASP.NET application. In .NET *Core*, it can use IIS, IIS Express or the standalone web app without explicit commands. Node.js is a *different* web server, separate from IIS Express and doesn't require it either. – Panagiotis Kanavos Jan 09 '23 at 10:04
  • 1
    For Rider, check [Run and debug .NET Core and ASP.NET Core apps with launch profiles](https://www.jetbrains.com/help/rider/Running_LaunchSettings.html). The `launchsettings.json` file is used by VS, Rider and the .NET CLI to specify launch profiles for web apps and can be configured to start multiple web apps, using any server combination. [Run and debug ASP.NET Core apps in IIS Express](https://www.jetbrains.com/help/rider/Running_IISExpress.html) shows how to configure IIS Express if needed. – Panagiotis Kanavos Jan 09 '23 at 10:08
  • Thanks, i will check it out. `You don't need to start the IIS Express service manually` - I know, but for my use It's convenient to do so, and later attach to the IIS express process to debug. I'm not alone with the CMS migrate, everything is as it should be except for this small issue. I know it's not necessary to start the IIS service manually, but makes my/our current workflow much more efficient than starting the service through the IDE after a new change in code. – hattemaker Jan 09 '23 at 10:38
  • If you want IIS to be already running, it's easier to use IIS itself instead of IIS Express. this will save you a few seconds *but* testing a self-hosted web app is even faster and *easier*, especially when you have to debug the startup code. – Panagiotis Kanavos Jan 09 '23 at 10:59

1 Answers1

1

I would recommend using Kestrel instead of IIS Express locally and simply start the site with: dotnet run

You can also use dotnet watch to automatically rebuild/restart the site when source code files change.

https://learn.microsoft.com/en-us/aspnet/core/getting-started/?view=aspnetcore-7.0&tabs=windows#run-the-app

Ted Nyberg
  • 7,001
  • 7
  • 41
  • 72