I have a Blazor Server .Net 8 web application. I right-click on the Blazor sever project and select "Add" then ".Net Aspire Orchestrator Support".
This added the two Projects (AppHost, and Service Defaults) to my solution. The AppHost project is selected as the start-up project. When I run the app in Debug mode it fails and I am getting the below-attached error.
Any idea what is wrong? It seems it's trying to convert a string to a boolean.
When I debug my app normally without using Aspire, I use IIS Express in Visual Studio
If it helps this is the full error msg
System.Text.Json.JsonException
HResult=0x80131500
Message=The JSON value could not be converted to System.Nullable`1[System.Boolean]. Path: $.profiles.DptBlazor.dotnetRunMessages | LineNumber: 27 | BytePositionInLine: 33.
Source=System.Text.Json
StackTrace:
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.ContinueDeserialize(ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Stream utf8Json)
at Aspire.Hosting.LaunchProfileExtensions.GetLaunchSettings(IProjectMetadata projectMetadata)
at Aspire.Hosting.LaunchProfileExtensions.GetLaunchSettings(ProjectResource projectResource)
at Aspire.Hosting.LaunchProfileExtensions.TrySelectLaunchProfileFromEnvironment(ProjectResource projectResource, String& launchProfileName)
at Aspire.Hosting.LaunchProfileExtensions.SelectLaunchProfileName(ProjectResource projectResource)
at Aspire.Hosting.LaunchProfileExtensions.GetEffectiveLaunchProfile(ProjectResource projectResource, Boolean throwIfNotFound)
at Aspire.Hosting.ProjectResourceBuilderExtensions.WithProjectDefaults(IResourceBuilder`1 builder, Boolean excludeLaunchProfile, String launchProfileName)
at Aspire.Hosting.ProjectResourceBuilderExtensions.AddProject[TProject](IDistributedApplicationBuilder builder, String name)
at Program.<Main>$(String[] args) in C:\inetpub\wwwroot\MyApp\Dpt.AppHost\Program.cs:line 3
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
InvalidOperationException: Cannot get the value of a token type 'String' as a boolean.
Im using IIS Express when I run it without Aspire and it works fine. But when I try and use Aspire i get the error
My launchSettings.json is below, im using Windows Auth:
{
"iisSettings": {
"windowsAuthentication": true,
"anonymousAuthentication": false,
"iis": {
"applicationUrl": "http://localhost/DptBlazor",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IIS",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
After cleaning up launchSettings.son I got it to run a bit more, but now I get an odd error.
My launching settings file is below:
{
"iisSettings": {
"windowsAuthentication": true,
"anonymousAuthentication": false,
"iisExpress": {
"applicationUrl": "http://localhost:61105",
"sslPort": 44392
}
},
"profiles": {
"IIS Express": {
"commandName": "IIS",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost/DptBlazor",
"dotnetRunMessages": true
},
"DptBlazor": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"dotnetRunMessages": true
}
}
}
Below is the code im using to get the Windows Authentication User Name, which seems to come back blank:
private readonly AuthenticationStateProvider authProvider;
var authenticationStateTask = await authProvider.GetAuthenticationStateAsync();
var user = authenticationStateTask.User;
if (user.Identity.IsAuthenticated)
{
return user.Identity.Name.Split('\\')[1]; ;
}









