3

I'm trying to host a ASP.NET Core 2.0 WebApplication in local IIS, but evertime i get the following error: Value cannot be null. Parameter name: name

enter image description here

The launchSettings.json file looks like this:

{
"iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iis": {
        "applicationUrl": "http://localhost/zoyotravel",
        "sslPort": 0
    },
    "iisExpress": {
        "applicationUrl": "http://localhost:56472/",
        "sslPort": 0
    }
},
"profiles": {
    "IIS Express": {
        "commandName": "IISExpress",
        "launchBrowser": true,
        "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
        }
    },
    "Zoyo Travel": {
        "commandName": "IIS",
        "launchBrowser": true,
        "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
        },
        "applicationUrl": "http://localhost:56473/"
    }
}
}

The program class looks liks this:

public class Program
{
    public static void Main(string[] args)
    {
        BuildWebHost(args).Run();
    }

    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .Build();
}

The startup class looks like this:

public class Startup
{
    // 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.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
            {
                HotModuleReplacement = true
            });
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
        }

        app.UseStaticFiles();

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");

            routes.MapSpaFallbackRoute(
                name: "spa-fallback",
                defaults: new { controller = "Home", action = "Index" });
        });
    }
}

What have I tried so far?

  • I have searched for all the parameters called "name" in the solution. But I could not find anything that could be empty.
  • If I host the website in IIS express then it works.

The problem does not appear to be in the code. It is also a standard asp.net core 2.0 web application. I did not touch the code itself. I have only tried to host the website in IIS.

Can somebody help me?

5
  • 1
    What does hosting have to do with the error? You get the error in Visual Studio, not from IIS Commented Oct 1, 2017 at 20:56
  • I'm trying to host the webapplication in local IIS, when i push the "start" button to run my project. The following error has occurded. Commented Oct 1, 2017 at 21:01
  • 1
    Please post program and startup classes Commented Oct 1, 2017 at 21:13
  • doesn't vs show you what is null? Commented Oct 2, 2017 at 5:24
  • Unfortunately, visual studio does not show what's null. I therefore find it difficult to indicate what is going wrong. If I build my webapp project, no errors will be displayed. Commented Oct 2, 2017 at 8:34

4 Answers 4

2

I had the same issue. I spent half a day trying every possible thing that I could think of.

Finally, I figured that

it was an issue with appsettings.json nesting.

I had to remove an extra } from the json file .

Since I cannot see your appsetting.json file here, it may be the problem in your case as well. Hope this helps.

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

Comments

2

I have encountered the same issue several times now. Initially I taught I was somehow messing something up because first time I started the app everything worked, but after a restart that "Value cannot be null. Parameter name: name" error appeared again. After some more experimenting with IIS I've discovered that creating and registering your app to a new application pool with the exact same specs, fallowed by iisreset solves this problem. The downside is that you have to do this whenever this error appears. After doing this once just switching between the two pools I now had and iisreset was enough. Hope it helps!

1 Comment

Thanks it worked for me, also while I'm using the " Development time IIS support" module I had to switch to "no managed code". So this problem is 100% from IIS
2

In my case issue was about 'uriString'. I don't know why but closing visual studio and opening fixed the issue. I hope it helps someone.

1 Comment

Same, also no clue why.
0

I faced the same issue while doing a Debug (F5).

Solved it as follows:

  1. Set your IIS Site App Pool to DefaultAppPool
  2. Run (F5)
  3. Revert to the actual app pool

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.