【发布时间】:2017-10-01 20:53:06
【问题描述】:
我正在尝试在本地 IIS 中托管 ASP.NET Core 2.0 WebApplication,但每次我收到以下错误:值不能为空。参数名称:名称
launchSettings.json 文件如下所示:
{
"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/"
}
}
}
程序类看起来像这样:
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
启动类如下所示:
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" });
});
}
}
到目前为止我尝试了什么?
- 我已经在解决方案中搜索了所有名为“名称”的参数。 但我找不到任何可能为空的内容。
- 如果我在 IIS express 中托管网站,那么它可以工作。
问题似乎不在代码中。它也是一个标准的 asp.net core 2.0 web 应用程序。我没有触及代码本身。我只尝试在 IIS 中托管网站。
有人可以帮帮我吗?
【问题讨论】:
-
主机与错误有什么关系?您在 Visual Studio 中得到错误,而不是来自 IIS
-
当我按下“开始”按钮运行我的项目时,我正在尝试在本地 IIS 中托管 Web 应用程序。出现以下错误。
-
请发布程序和启动类
-
不向你展示什么是 null?
-
不幸的是,Visual Studio 不显示什么是空的。因此,我发现很难指出哪里出了问题。如果我构建我的 webapp 项目,将不会显示任何错误。
标签: c# asp.net-core