I have created a simple ASP.NET Core web application with the following steps:
Created an Empty template of ASP.NET core project:
Added a wwwroot folder with an index.html page in it.
Startup.cs is pretty default with just one extra line added:
app.UseDefaultFiles();
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace WebApplication1
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseDefaultFiles();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Hello World!");
});
});
}
}
}
Build the solution and pointed my IIS web site to the root of the web project:
All I see an empty page on running the site via IIS (no console error, permissions already give to the root of the solution):
I was expecting the output of index.html to have come there at the root of the application URL. Is there any special which needs to be done for an ASP.NET core project to make it running via IIS?
I would like to debug too by attaching the IIS process in Visual Studio for that given site?
Can you share what I am missing there?
The same steps seem to be working with the ASP.NET framework. I don't want to execute Run command on the VS and run the site on localhost, my goal is to run the site with IIS/ with a valid url so that I can debug too directly by attaching the process with Visual Studio solution.