Blazor app is not loading after deployed to iis server

I have deployed my app to a IIS server and am getting the following error when the page tries to load

Error 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()

any help would be amazing!

thanks :slight_smile:

I'm afraid that I've never seen such error before. What happens if you deploy the same app using Visual Studio?

I get the same error when I deploy using Visual Studio

Check if you have Hosting Bundle installed at all:

we are installing that now also here is my publish settings in visual studio

am I doing anything wrong here?

As far as I can see your application is .NET 6 - you need to have relevant .NET installed on your machine with the IIS.For other questions related to deploying Blazor applications with Visual Studio, IIS, what needs to be installed you can ask on official Microsoft forums or StackOverflow.