Skip to content

Blazor is unable to deserialize date in the case of pre-rendering When the date is not set explicitly #12046

Closed
@iAmBipinPaul

Description

@iAmBipinPaul

Blazor is unable to deserialize date in the case of pre-rendering When the date is not stated explicitly

After configuring pre-rendering on ASP.NET Core hosted it works as expected but when I'm configuring the part of the code where the date is being set, it throws an exception

JsonException: The JSON value could not be converted to System.DateTime. Path: $[0].date |
 LineNumber: 0 | BytePositionInLine: 30.

Works

 return Enumerable.Range(1, 5).Select(index => new WeatherForecast
            {
               Date = DateTime.Now.AddDays(index),
                TemperatureC = rng.Next(-20, 55),
                Summary = Summaries[rng.Next(Summaries.Length)]
            });

Does not work

 return Enumerable.Range(1, 5).Select(index => new WeatherForecast
            {
                //Date = DateTime.Now.AddDays(index),
                TemperatureC = rng.Next(-20, 55),
                Summary = Summaries[rng.Next(Summaries.Length)]
            });

sample project
https://github.com/iAmBipinPaul/Prerendering

Metadata

Metadata

Assignees

Labels

area-blazorIncludes: Blazor, Razor Components

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions