ubuntu下面运行asp.net core 不加载appsettings.json配置文件

easy999000 1 Reputation point
2021-10-25T02:23:56.96+00:00

我做了一个asp.net core5.0的站点,发布在ubuntu服务器上,
发现如果我不在程序所在文件夹下面运行站点,站点遍不会加载 appsettings.json配置文件

只要不在程序所在文件夹去启动站点,其他任何文件夹都不会加载 appsettings.json配置文件,这是为什么呢??

143188-file.png

143140-image.png

Developer technologies | ASP.NET | ASP.NET Core
Developer technologies | .NET | .NET Runtime
{count} votes

1 answer

Sort by: Most helpful
  1. SY LI 0 Reputation points
    2025-03-26T07:21:57.06+00:00

    System.ArgumentNullException: Value cannot be null. (Parameter 's')

    at System.ArgumentNullException.Throw(String paramName)

    at System.Text.Encoding.GetBytes(String s)

    at Crane.Common.SetupExtensions.AuthenticationSetup.<>c__DisplayClass0_0.<AddAuthenticationSetup>b__1(JwtBearerOptions options) in D:\Webproject\Crane\Crane.Common\SetupExtensions\AuthenticationSetup.cs:line 38

    at Microsoft.Extensions.Options.ConfigureNamedOptions`1.Configure(String name, TOptions options)

    at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)

    at Microsoft.Extensions.Options.OptionsMonitor1.<>c.<Get>b__10_0(String name, IOptionsFactory1 factory)

    at Microsoft.Extensions.Options.OptionsCache1.<>c__DisplayClass3_11.<GetOrAdd>b__2()

    at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)

    at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)

    at System.Lazy`1.CreateValue()

    at Microsoft.Extensions.Options.OptionsCache1.GetOrAdd[TArg](String name, Func3 createOptions, TArg factoryArgument)

    at Microsoft.Extensions.Options.OptionsMonitor`1.Get(String name)

    at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.InitializeAsync(AuthenticationScheme scheme, HttpContext context)

    at Microsoft.AspNetCore.Authentication.AuthenticationHandlerProvider.GetHandlerAsync(HttpContext context, String authenticationScheme)

    at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme)

    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)

    at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)

    at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)

    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequestsTContext

    Why not answer ?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.