3
votes

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).
Modules

I also adapted the application pool:

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?

1
Try you chance by adding .UseIISIntegration() to your BuildWebHost. It may be helpful.Salah Akbari
@S.Akbari I can add it but I tried it before and it didn't change anything.kevingoos
I think that was required in ASP.NET Core 1.0Peter Hedberg

1 Answers

0
votes

It is a stupid mistake on my part, apparently I used the wrong url. But my config posted here works!