首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >System.InvalidOperationException:“只能使用IApplicationBuilder.UsePathBase()配置路径库。”

System.InvalidOperationException:“只能使用IApplicationBuilder.UsePathBase()配置路径库。”
EN

Stack Overflow用户
提问于 2017-10-14 21:15:28
回答 1查看 28.8K关注 0票数 39

我有一个在Docker中运行的ASP.Net核心2解决方案,它在1台机器上运行良好,运行的是VS 2017专业人员,但在另一台运行VS 2017社区的机器上运行,我得到以下错误

"System.InvalidOperationException:‘只能使用IApplicationBuilder.UsePathBase()配置路径库’。“

当我尝试使用docker启动或调试解决方案时。如果我用IIS启动解决方案,它可以正常工作。

我的项目没有什么特别之处:

代码语言:javascript
运行
复制
public class Program
{
    public static void Main(string[] args)
    {
        BuildWebHost(args).Run(); // <- Exception happens here
    }

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

public class Startup
{
    public Startup(IHostingEnvironment env)
    {

    }

    public IConfiguration Configuration { get; }

    // 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.UseMvc();
    }
}

我还在一个新窗口里弹出了这个:

代码语言:javascript
运行
复制
crit: Microsoft.AspNetCore.Server.Kestrel[0]
      Unable to start Kestrel.
System.InvalidOperationException: A path base can only be configured using IApplicationBuilder.UsePathBase().
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindAddressAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.<BindAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<StartAsync>d__21`1.MoveNext()

我在这个问题上读到的所有东西似乎都与此无关。有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2020-06-16 06:56:48

我在applicationUrl中设置了launchSettings.json中的相对路径,这导致了错误:

代码语言:javascript
运行
复制
"applicationUrl": "https://localhost:5001/admin",

我将其更改为根URL,并添加了一个launchUrl,其中包含了修复错误的路径,并在开始时启动了我想要的路径:

代码语言:javascript
运行
复制
"applicationUrl": "https://localhost:5001",
"launchUrl": "admin"
票数 88
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46749411

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档