Reputation: 1542
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
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?
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?
Upvotes: 3
Views: 8175
Reputation: 41
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.
Upvotes: 2
Reputation: 4324
I faced the same issue while doing a Debug (F5).
Solved it as follows:
Upvotes: 0
Reputation: 1344
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.
Upvotes: 2
Reputation: 29
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!
Upvotes: 2