【发布时间】:2019-04-03 21:17:43
【问题描述】:
我正在尝试部署一个 asp net core 2 应用程序,一切似乎都很好,我在 VS2017 中使用部署文件选项,到我的路径 inetpub\wwwroot\App1 文件夹,我添加了应用程序。 我浏览到路径http://localhost:8088/App1/Home/Index/ 然后我看到了:
ArgumentException:“value”中的路径必须以“/”开头。 Nombre del parametro: 价值 Microsoft.AspNetCore.Http.PathString..ctor(字符串值) Microsoft.AspNetCore.Builder.ExceptionHandlerExtensions.UseExceptionHandler(IApplicationBuilder 应用程序,字符串错误处理路径) OCIndicadoresOperativoClientes.Startup.Configure(IApplicationBuilder 应用程序,IHostingEnvironment env)在 Startup.cs System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder 应用程序) Microsoft.AspNetCore.Server.IISIntegration.IISSetupFilter+c__DisplayClass3_0.b__0(IApplicationBuilder 应用程序) Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter+c__DisplayClass0_0.b__0(IApplicationBuilder 建设者) Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
下面可以看到Startup.cs的代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.SpaServices.Webpack;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace App1
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddDistributedMemoryCache();
services.AddMvc().AddSessionStateTempDataProvider();
services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromMinutes(25);
options.Cookie.HttpOnly = true;
});
services.AddAuthenticationCore();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseExceptionHandler("App1/Home/Error");
app.UseStaticFiles();
app.UseSession();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "Home",
template: "{controller=Home}/{action=Index}/{id?}");
routes.MapRoute(
name: "Shippers",
template: "{controller=ControllerB}/{action=Index}/{id?}");
routes.MapSpaFallbackRoute(
name: "spa-fallback",
defaults: new { controller = "Home", action = "Index" });
routes.MapSpaFallbackRoute(
name: "ControllerB",
defaults: new { controller = "ControllerB", action = "Index" });
});
}
}
}
另外,我将包含 webconfig 详细信息:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\App1.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
您是否发现任何错误?感谢您的帮助!
【问题讨论】:
标签: asp.net-mvc asp.net-core deployment visual-studio-2017