razor-pages

Razor Pages - Model validation fails due to multiple objects sharing parameters

我与影子孤独终老i 提交于 2020-08-24 08:29:08
问题 I am running into an issue that I cannot seem to wrap my head around. I am using Razor Pages and have two objects that can be bound. [BindProperty] public MeetingMinuteInputDto MeetingToCreate { get; set; } [BindProperty] public MeetingMinuteUpdateDto MeetingToUpdate { get; set; } Above two are separate dto for creating/updating a base entity in my database. I have two separate dto because I allow only specific items for update (to prevent overposting). Both classes have a Name , Date , and

How to render full RazorPage to string?

倖福魔咒の 提交于 2020-07-23 06:38:43
问题 I tried to use the solution from https://stackoverflow.com/a/54043063/234954, to render a page as a string (so I can turn it into a PDF), but that only gets me the main view, it doesn't get the layout associated with the page (and so it is missing the style sheets and some header/footers). How can I render the full page as a string, and not just the partial view? 回答1: I used this article code in a recent project to render html to feed into PDF generation. I used templates in the Views folder

IntelliSense not working for CSS files in .NET Core 3.1 Razor Class Library when accessed from referencing web applications

久未见 提交于 2020-07-22 07:54:08
问题 I am creating a reusable UI utilizing a .NET Core 3.1 Razor Class Library (RCL) as documented here: https://docs.microsoft.com/en-us/aspnet/core/razor-pages/ui-class?view=aspnetcore-3.1&tabs=visual-studio I am able to create an RCL that includes static assets, and am able to utilize them as documented in the link above. By default, Visual Studio 2019 (16.5.1) only provides IntelliSense for the CSS/JavaScript files in the RCL project itself, not from any of the dependent projects. There is a

IntelliSense not working for CSS files in .NET Core 3.1 Razor Class Library when accessed from referencing web applications

南笙酒味 提交于 2020-07-22 07:51:29
问题 I am creating a reusable UI utilizing a .NET Core 3.1 Razor Class Library (RCL) as documented here: https://docs.microsoft.com/en-us/aspnet/core/razor-pages/ui-class?view=aspnetcore-3.1&tabs=visual-studio I am able to create an RCL that includes static assets, and am able to utilize them as documented in the link above. By default, Visual Studio 2019 (16.5.1) only provides IntelliSense for the CSS/JavaScript files in the RCL project itself, not from any of the dependent projects. There is a

IntelliSense not working for CSS files in .NET Core 3.1 Razor Class Library when accessed from referencing web applications

陌路散爱 提交于 2020-07-22 07:51:04
问题 I am creating a reusable UI utilizing a .NET Core 3.1 Razor Class Library (RCL) as documented here: https://docs.microsoft.com/en-us/aspnet/core/razor-pages/ui-class?view=aspnetcore-3.1&tabs=visual-studio I am able to create an RCL that includes static assets, and am able to utilize them as documented in the link above. By default, Visual Studio 2019 (16.5.1) only provides IntelliSense for the CSS/JavaScript files in the RCL project itself, not from any of the dependent projects. There is a

Is it possible to deploy an uncompiled ASP.NET Razor Pages website?

蓝咒 提交于 2020-07-22 05:04:30
问题 I am wondering if it is possible to copy the source code of an ASP.NET Razor Pages website to a Windows web server and for it to run without it needing to be published/compiled? Similar to what you can do with ASP.NET Web Forms websites where you upload the source code (*.aspx and *.aspx.cs files) and they compile at runtime? I saw something about Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation but I wasn't sure if this is what I was after and how to use it. Is this possible and any

Adding Assemblies/Types to be made available to Razor Page at Runtime

不打扰是莪最后的温柔 提交于 2020-07-17 17:59:27
问题 I'm trying to build a dynamic Web interface where I can dynamically point at a folder and serve Web content out of that folder with ASP.NET Core. This works fairly easily by using FileProviders in ASP.NET Core to re-route the Web root folder. This works both for StaticFiles and For RazorPages. However, for RazorPages the problem is that once you do this you can't dynamically add references for additional types. I'd like to be able to optionally add a folder (PrivateBin) which on startup I can

Howto debug JavaScript inside ASP .Net Core 3.1 MVC applications (Razor view - *.cshtml)?

☆樱花仙子☆ 提交于 2020-07-07 19:55:24
问题 I have latest Visual Studio 2019 16.5.4 Enterprise . I've just created an ASP .Net Core 3.1 MVC application from a template (with default settings). And I've added some JavaScript code to a Home Page's Index.cshtml : @{ ViewData["Title"] = "Home Page"; } <div class="text-center"> <h1 class="display-4">Welcome</h1> <p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p> </div> @section Scripts { <script> function GetJSON_Simple() { var resp

Multi Tenant Razor pages

与世无争的帅哥 提交于 2020-06-27 09:03:12
问题 I am trying to set up Razor Pages routing to allow different views to be rendered for different tenants. I have a directory structure as follows: /Pages Test.cshtml.cs /Tenant1 Test.cshtml /Tenant2 Test.cshtml Given I am already able to decide which tenant is required, how is it possible to configure the routing to map some path eg localhost:8080/Test to either Tenant1/Test or Tenant2/Test views. 回答1: Use dynamic view content (via partial views). With this solution, the Test page will

Routing Razor Pages to /example.com/en/ format

你。 提交于 2020-06-27 04:27:07
问题 I have three languages on my website. I'm trying to get my razor pages to route to culture/localization like so: https://localhost:44396/en/ https://localhost:44396/ru/ I have hundreds of lines of code commented out at this point using methods I've been googling for the past two days and nothing seems to do the job. The website is mostly static so right now beyond the culture there is nothing else that needs routing. 回答1: Here's a way you can do it that doesn't require you to put a middleware