How to run net 6 core application inside virtual directory i,e inside the default web site on IIS.
Loading
How to run net 6 core application inside virtual directory i,e inside the default web site on IIS.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sam HobbsRank #107 · 20.5K reputationPosted Jan 10, 2024, 11:38 AM EST
This depends on whether it is for production or not. If not for production and if for only use locally then you can use the Kestrel server that is included in the application by default. You can use
dotnet runto do that.The following article is Microsoft's instructions for hosting an ASP.NET Core application on Windows using IIS.
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-8.0
Anandu G NathRank #681 · 3.5K reputationPosted Jan 10, 2024, 10:46 PM EST
To run a .NET 6 Core application inside a virtual directory, you'll need to make some adjustments to your project and possibly the hosting configuration. Here are the general steps:
Update Your Project File: Open your
.csprojfile and make sure it has the following configuration:Configure Application Base Path: In your
Program.csfile, update theWebHostBuilderto set the base path for your application:var host = Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseContentRoot(Directory.GetCurrentDirectory()); webBuilder.UseUrls("http://localhost:5000"); webBuilder.UseStartup(); }) .Build();Jayraj ChhayaRank #304 · 8.2K reputationPosted Jan 11, 2024, 1:29 AM EST
To run a .NET 6 Core application inside a virtual directory on IIS, you need to follow these steps:
Now, your .NET 6 Core application is configured to run inside the virtual directory on the default website in IIS. You can access it by navigating to the virtual directory URL in a web browser.
Please note that these steps assume you have already installed the necessary prerequisites for running .NET 6 Core applications on your server, such as the .NET 6 runtime and hosting bundle.