Blazor 应用程序部署到 iis 服务器后未加载

问题描述 投票:0回答:1

我已将应用程序部署到 IIS 服务器,当页面尝试加载时出现以下错误

我收到此页面不工作网站当前无法处理此请求。 HTTP 错误 500

这些是我在服务器上的 Web 控制台中收到的错误: 错误1:

Category: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware

EventId: 1

SpanId: 12f6fabbd939776b

TraceId: dc6a807e12054525cd255c7011d0b709

ParentId: 0000000000000000

RequestId: 80000061-0001-fc00-b63f-84710c7967bb

RequestPath: /surplus

An unhandled exception has occurred while executing the request.

Exception:

System.UriFormatException: Invalid URI: The format of the URI could not be determined.

at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)

at System.Uri..ctor(String uriString)

at Microsoft.Identity.Web.AuthorityHelpers.BuildAuthority(MicrosoftIdentityOptions options)

at Microsoft.Identity.Web.MicrosoftIdentityWebAppAuthenticationBuilderExtensions.<>c__DisplayClass5_0.b__3(OpenIdConnectOptions options, IServiceProvider serviceProvider, IOptionsMonitor1 mergedOptionsMonitor, IOptionsMonitor1 msIdOptionsMonitor, IOptions`1 msIdOptions)

at Microsoft.Extensions.Options.ConfigureNamedOptions`5.Configure(String , TOptions )

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

at Microsoft.Extensions.Options.OptionsMonitor`1.<>c__DisplayClass10_0.b__0()

at System.Lazy`1.ViaFactory(LazyThreadSafetyMode )

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

at System.Lazy`1.CreateValue()

at System.Lazy`1.get_Value()

at Microsoft.Extensions.Options.OptionsCache1.GetOrAdd(String , Func1 )

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

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.AuthenticationMiddleware.Invoke(HttpContext context)

at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

Error 2:

Category: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware

EventId: 3

SpanId: 12f6fabbd939776b

TraceId: dc6a807e12054525cd255c7011d0b709

ParentId: 0000000000000000

RequestId: 80000061-0001-fc00-b63f-84710c7967bb

RequestPath: /surplus

An exception was thrown attempting to execute the error handler.

Exception:

System.UriFormatException: Invalid URI: The format of the URI could not be determined.

at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)

at System.Uri..ctor(String uriString)

at Microsoft.Identity.Web.AuthorityHelpers.BuildAuthority(MicrosoftIdentityOptions options)

at Microsoft.Identity.Web.MicrosoftIdentityWebAppAuthenticationBuilderExtensions.<>c__DisplayClass5_0.b__3(OpenIdConnectOptions options, IServiceProvider serviceProvider, IOptionsMonitor1 mergedOptionsMonitor, IOptionsMonitor1 msIdOptionsMonitor, IOptions`1 msIdOptions)

at Microsoft.Extensions.Options.ConfigureNamedOptions`5.Configure(String , TOptions )

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

at Microsoft.Extensions.Options.OptionsMonitor`1.<>c__DisplayClass10_0.b__0()

at System.Lazy`1.ViaFactory(LazyThreadSafetyMode )

--- End of stack trace from previous location ---

at System.Lazy`1.CreateValue()

at System.Lazy`1.get_Value()

at Microsoft.Extensions.Options.OptionsCache1.GetOrAdd(String , Func1 )

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

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.AuthenticationMiddleware.Invoke(HttpContext context)

at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.HandleException(HttpContext context, ExceptionDispatchInfo edi)

Error 3:

Category: Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer

EventId: 2

SpanId: 12f6fabbd939776b

TraceId: dc6a807e12054525cd255c7011d0b709

ParentId: 0000000000000000

RequestId: 80000061-0001-fc00-b63f-84710c7967bb

RequestPath: /surplus

Connection ID "18158513703463419998", Request ID "80000061-0001-fc00-b63f-84710c7967bb": An unhandled exception was thrown by the application.

Exception:

System.UriFormatException: Invalid URI: The format of the URI could not be determined.

at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)

at System.Uri..ctor(String uriString)

at Microsoft.Identity.Web.AuthorityHelpers.BuildAuthority(MicrosoftIdentityOptions options)

at Microsoft.Identity.Web.MicrosoftIdentityWebAppAuthenticationBuilderExtensions.<>c__DisplayClass5_0.b__3(OpenIdConnectOptions options, IServiceProvider serviceProvider, IOptionsMonitor1 mergedOptionsMonitor, IOptionsMonitor1 msIdOptionsMonitor, IOptions`1 msIdOptions)

at Microsoft.Extensions.Options.ConfigureNamedOptions`5.Configure(String , TOptions )

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

at Microsoft.Extensions.Options.OptionsMonitor`1.<>c__DisplayClass10_0.b__0()

at System.Lazy`1.ViaFactory(LazyThreadSafetyMode )

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

at System.Lazy`1.CreateValue()

at System.Lazy`1.get_Value()

at Microsoft.Extensions.Options.OptionsCache1.GetOrAdd(String , Func1 )

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

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.AuthenticationMiddleware.Invoke(HttpContext context)

at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.HandleException(HttpContext context, ExceptionDispatchInfo edi)

at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()

任何帮助都会很棒!

谢谢:)

c# iis blazor
1个回答
0
投票

System.UriFormatException with Invalid URI: The format of the URI could not be determined
消息是几乎总是与代码相关的错误之一。

根本原因:

如果输入值不是应用程序期望的值,则会生成此异常。换句话说,应用程序期望一个有效的 URI,但它收到的值不是 URI 格式。

解决方案:

此问题可能是由于用户行为(提交到函数中的值)而发生的。无论根本原因是什么,应用程序都应该捕获异常。在该函数中实现 try-catch 块来处理此异常。

它还有助于查找引发错误的程序集(查看堆栈跟踪以获取此信息)。如果它是第三方组件,您将需要联系他们。他们可能已经修复或更新了程序集。

您还可以尝试弄清楚该值是如何传递给该函数的。检查输入和用例。询问您的用户重现它的步骤。这可能是因为用户在表单中输入了无效信息。但是,无论输入是什么,应用程序都应该捕获异常。

来源

https://techcommunity.microsoft.com/t5/iis-support-blog/system-uriformatexception/ba-p/984827

© www.soinside.com 2019 - 2024. All rights reserved.