4

I am trying to host a ASP.net Core WebAPI like the Microsoft Docs tell me: Hosting in ASP.NET Core

Configuration

I am Running IIS 10 on Windows Server 2016, where Web Deploy 3.6, .Net Core Runtime 2.0.7 and .NET Core Server Hosting Bundle is installed.

The Web API is configured as follows:

Program.cs :

public static IWebHost BuildWebHost(string[] args) {
    IConfigurationRoot config = new ConfigurationBuilder()
        .SetBasePath(Directory.GetCurrentDirectory())
        .AddJsonFile("appsettings.json")
        .Build();

    return WebHost.CreateDefaultBuilder(args)
              .UseConfiguration(config)
              .UseStartup<Startup>()
              .UseKestrel(opt => {
                  opt.Listen(IPAddress.Loopback, 4000);
              })
              .UseIISIntegration()
              .Build();
}

web.config :

<?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=".\Agent.DuZu.Web.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>

On the IIS, the ASP.net Core Module is activated and i have a Site with a binding on port 80.

Problem

I am publishing the App on the server with WebDeploy, but the Application just won't start. There is no Output nor Error. I'm not sure if i am missing something or if my Configuration is just fail. Also I would like to know, if there is a way to see the running App.

17
  • Have you verified that all files are being transferred via WebDeploy. Does the same thing happen if you FTP the files? Commented Apr 25, 2018 at 7:47
  • All files are getting deploed at the server. I have also tried with FTP, same behaviour. Commented Apr 25, 2018 at 7:51
  • What exactly is the error message? Commented Apr 25, 2018 at 7:53
  • @TanveerBadar thats the problem, there is no error message. It just puts the files up there and nothing is happening. Commented Apr 25, 2018 at 7:56
  • Did you tried installing the SDK just to make sure it's not related to missing dependencies? Without an error is hard to reason what's going on. Your web.config is exactly like one I have working so.. Commented Apr 25, 2018 at 10:08

2 Answers 2

6

With the help of my collegue i figured out the solution:

Permissions:

The IIS has to have Permissions on the site folders. One has to check, that the applicationpool user has permission on the Folders.

I have granted the "LOCAL SERVICE" on my "C:\inetpub\sites" folder where all my sites belong, as well as on the application pool i am using.

web.config

The WebDeploy has overwritten the web.config and changed it to:

<aspNetCore processPath=".\Agent.DuZu.Web.exe" 
    arguments=".\Agent.DuZu.Web.dll"
    stdoutLogEnabled="true" 
    stdoutLogFile=".\logs\stdout" 
    forwardWindowsAuthToken="false" />

So the stdout log showed an Argument Error. The Solution to this is changing the processPath to "dotnet" as described in this question.

<aspNetCore processPath="dotnet" 
    arguments=".\Agent.DuZu.Web.dll"
    stdoutLogEnabled="true" 
    stdoutLogFile=".\logs\stdout" 
    forwardWindowsAuthToken="false" />

Another thing to mention is, that the "logs" folder has to be created, because IIS won't do this by itself.

Sign up to request clarification or add additional context in comments.

Comments

2

This also occurred for me in a new project in which the module was specified as AspNetCoreModuleV2:

  <handlers>
    <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
  </handlers>

Presumably I did not have it installed. I saw that in an older .NET Core website of mine, the module was not V2. Removing the V2 from the module specification fixed it in my instance:

  <handlers>
    <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
  </handlers>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.