I am trying to run my .NET Core 2.0 app on IIS but I always get a webpage cannot be found 404 exceptions.
When I go to the event viewer I get the following message:
Application 'MACHINE/WEBROOT/APPHOST/SPADWATCH' started process '516' successfully and is listening on port '18579'.
This is the setup that I did:
I followed the following guide as close as possible: Guide.
First I installed .NET Core runtime (as you can see inside the modules page).
I also adapted the application pool:
This is the code I have in my program.cs file:
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
My startup.cs
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc();
}
}
And the web.config that is auto generated:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\TestWebApplication1.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
<!--ProjectGuid: 5a95b46e-f37a-4205-b510-9fdc76cdddfa-->
Am I forgetting something?
.UseIISIntegration()
to yourBuildWebHost
. It may be helpful. – Salah Akbari