.NET Core 3.0: Razor views don’t automatically recompile on change

For ASP.NET Core 3 release version: services.AddControllersWithViews().AddRazorRuntimeCompilation(); https://learn.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-3.0 It can also be enabled conditionally only for local development, quoted from the link: Runtime compilation can be enabled such that it’s only available for local development. Conditionally enabling in this manner ensures that the published output: Uses compiled views. Is smaller in size. Doesn’t enable file … Read more

Where are the Login and Register pages in an AspNet Core scaffolded app?

It was announced during the preview of asp.net core 2.1 that the Identity UI would be moved to a new Razor Class Library. https://blogs.msdn.microsoft.com/webdev/2018/03/02/aspnetcore-2-1-identity-ui/ It is still possible to scaffold the Identity Views into your own project if you prefer local views: https://docs.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-2.1&tabs=visual-studio

Example AJAX call back to an ASP.NET Core Razor Page

Razor Pages automatically generates and validates Antiforgery tokens to prevent CSRF attacks. Since you aren’t sending any token within your AJAX callback, the request fails. To solve this problem you will have to: Register the Antiforgery-Service Add the token to your request Add the antiforgery token to your page either by adding a <form> or … Read more

Input box as “date” on web when model is “int”

Use View Model to bind view instead of actual model, which will contain DateTime type of property. Then Map View Model to actual Entity Model. View Model: class AgrRowVM { public DateTime? FrDt {get; set;} //Rest of the properties } Model: class AgrRow { public int? FrDt {get; set;} //Rest of the properties } After … Read more

tech