Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Razor slice with name '/Slices/Home.cshtml' was found but it's model type is DateTime.

See original GitHub issue

Just found this project and was considering adding it to a Carter extension package so you can content negotiate (which Carter already supports) HTML from the Carter/Minimal API routes.

Have followed the instructions but get the titled exception.

I also tried it with my own POCO as the model and get the same error

Any ideas?

System.InvalidOperationException: Razor slice with name '/Slices/Home.cshtml' was found but it's model type is DateTime.
   at RazorSlices.RazorSlice.ResolveSliceFactoryImpl[TModel](String sliceName) in /_/src/RazorSlices/RazorSlice.ResolveAndCreate.cs:line 445
   at RazorSlices.RazorSlice.ResolveSliceFactory[TModel](String sliceName) in /_/src/RazorSlices/RazorSlice.ResolveAndCreate.cs:line 292
   at RazorSlices.RazorSlice.Create[TModel](String sliceName, TModel model) in /_/src/RazorSlices/RazorSlice.ResolveAndCreate.cs:line 353
   at RazorSlices.RazorSlice.CreateHttpResult[TModel](String sliceName, TModel model, Int32 statusCode) in /_/src/RazorSlices/RazorSlice.CreateHttpResult.cs:line 58
   at Microsoft.AspNetCore.Http.HttpResultsExtensions.RazorSlice[TModel](IResultExtensions resultExtensions, String sliceName, TModel model, Int32 statusCode) in /_/src/RazorSlices/HttpResultsExtensions.cs:line 53
   at Carter.HtmlNegotiator.Razor.RazorResponseNegotiator.Handle(HttpRequest req, HttpResponse res, Object model, CancellationToken cancellationToken) in /Users/jonathan/Projects/Carter.HtmlNegotiator/src/Razor/RazorResponseNegotiator.cs:line 18

Issue Analytics

  • State:closed
  • Created 5 months ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

jchannoncommented, Apr 19, 2023

Thanks, it actually turned out to be a bit easier in that I could change the existing IResponseNegotiator to be generic =)

Thanks for the help

jchannoncommented, Apr 18, 2023

Yeah looking into adding a IResponseNegotiator<T> interface into Carter

Read more comments on GitHub >

github_iconTop Results From Across the Web mvc 3 - Converting DateTime format using razor
I understand this is how Microsoft expects this to work, but it just seems data display formatting should be isolated to the view...
Read more >
Razor syntax reference for ASP.NET Core
Razor is a markup syntax for embedding .NET based code into webpages. The Razor syntax consists of Razor markup, C#, and HTML. Files...
Read more >
Dates And Times in a Razor Pages Form
These include options for managing the date and time, just the date or time, and for working with the month or week of...
Read more >
Basics of Razor Pages - .NET Tools Guide
A complete Razor Pages pipeline. ... Razor Pages is a newer, simplified web application programming model. It removes much of the ceremony of...
Read more >
Razor Slices
Razor Slices. CI (main) Nuget. Lightweight Razor-based templates for ASP.NET Core without MVC, Razor Pages, or Blazor, optimized for high-performance ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found