razor-pages

Server-side Blazor page post to Razor page http error 400

别来无恙 提交于 2020-05-16 12:31:24
问题 I am trying to post my username and password from a Blazor page (.razor) to a Razor Page(.cshtml) but I get http error 400 all the time. LoginControl.razor <form method="post" action="login"> <input type="text" name="username" @bind="@Username" placeholder="User Name" />    <input type="password" name="password" placeholder="Password" @bind="@Password" />    <button class="ml-md-auto btn btn-primary">Loggin</button> </form> Login.cshtml.cs public async Task<IActionResult> OnPostAsync(

ASP .Net Core 3.0 ShortName in the Display Attribute (DataAnnotations)

霸气de小男生 提交于 2020-05-15 11:50:07
问题 This question was asked in the past and the answer here https://stackoverflow.com/a/45236544/3074765 has been a life saver for me. The problem is that when I migrated to .Net Core 3.0, it broke. The reason can be found here https://github.com/aspnet/AspNetCore/issues/8678 . In a nutshell, Microsoft had made some functions public that were in a class that was labeled internal. Fixing this removed access to ExpressionMetadataProvider. Consider the following HTML Helper using Microsoft

ASP.NET Core 2.1 Razor page return Page with model

烂漫一生 提交于 2020-05-15 06:52:25
问题 I am using ASP.NET Core 2.1 for creating an identity server. I use the Asp Identity and I scaffolded the login and register pages. I have the following page: [AllowAnonymous] public class RegisterModel : PageModel { ...... public string ReturnUrl { get; set; } ...... public void OnGet(string returnUrl = null) { ReturnUrl = returnUrl; } public async Task<IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); if (ModelState.IsValid) { return

Cannot post JSON to an ASP.NET Core RazorPage handler

给你一囗甜甜゛ 提交于 2020-05-15 05:56:08
问题 I'm working with an ASP.NET Core RazorPage as an alternative to an MVC controller, and I want to be able to submit the client side form via XMLHttpRequest. I've already figured out the XSRF token bits so that passes the muster, but the RazorPages framework doesn't seem to process the inbound JSON payload and bind it to the property as expected. Some code: The page's model (.cshtml.cs): public class IndexModel : PageModel { private Database database; private ILogger logger; [BindProperty]

How can Add Area in razor pages on dot net core 3.0/3.1?

前提是你 提交于 2020-05-13 11:41:39
问题 I want to add areas in core 3.1 in Razor Pages , but Microsoft documents are for asp dot net core 2.2, and they want to create a new report in January 2020!. Does somebody know how to add areas to the core 3.1? I searched a lot on Google but couldn't find an answer. in _AdminLayout : ... <a asp-area="Channel" asp-page="Index" class="w3-bar-item w3-button w3-padding"><i class="fad fa-cog"></i>  تنظیمات آپارات</a> <a asp-page="Channel/Index" class="w3-bar-item w3-button w3-padding"><i class=

How can Add Area in razor pages on dot net core 3.0/3.1?

泄露秘密 提交于 2020-05-13 11:41:05
问题 I want to add areas in core 3.1 in Razor Pages , but Microsoft documents are for asp dot net core 2.2, and they want to create a new report in January 2020!. Does somebody know how to add areas to the core 3.1? I searched a lot on Google but couldn't find an answer. in _AdminLayout : ... <a asp-area="Channel" asp-page="Index" class="w3-bar-item w3-button w3-padding"><i class="fad fa-cog"></i>  تنظیمات آپارات</a> <a asp-page="Channel/Index" class="w3-bar-item w3-button w3-padding"><i class=

Custom validation fires if in model class but not on page property

三世轮回 提交于 2020-04-30 06:26:22
问题 I have a contact Razor page implemented in ASP.NET Core 2.0. I am using model binding and custom validation. If I use custom validation on a separate model class, the validation method is called. If I use custom validation on a property on the PageModel, the validation method is not called. However, all properties are successfully bound. Here's the PageModel class and the separate model class: public class ContactModel : PageModel { [BindProperty] public ContactMessageModel

How to navigate to a new bootstap 4 tab on the same page from a sidebar link?

£可爱£侵袭症+ 提交于 2020-04-17 21:41:29
问题 I'm unable to get sidebar links to navigate to bootstrap 4 tabs on the center page using this technique. Here is the javascript in my _SidebarLayout.cshtml : <script> function selectTabNamedInUrlHash() { let selectedTab = window.location.hash; $('.nav-link[href="' + selectedTab + '"]').trigger('click'); } jQuery(document).ready(function ($) { selectTabNamedInUrlHash(); }) </script> A sidebar anchor links to the page and adds a fragment (hash) to the href of the tab I want to navigate to (url

How to navigate to a new bootstap 4 tab on the same page from a sidebar link?

扶醉桌前 提交于 2020-04-17 21:40:56
问题 I'm unable to get sidebar links to navigate to bootstrap 4 tabs on the center page using this technique. Here is the javascript in my _SidebarLayout.cshtml : <script> function selectTabNamedInUrlHash() { let selectedTab = window.location.hash; $('.nav-link[href="' + selectedTab + '"]').trigger('click'); } jQuery(document).ready(function ($) { selectTabNamedInUrlHash(); }) </script> A sidebar anchor links to the page and adds a fragment (hash) to the href of the tab I want to navigate to (url

How to navigate to a new bootstap 4 tab on the same page from a sidebar link?

|▌冷眼眸甩不掉的悲伤 提交于 2020-04-17 21:40:27
问题 I'm unable to get sidebar links to navigate to bootstrap 4 tabs on the center page using this technique. Here is the javascript in my _SidebarLayout.cshtml : <script> function selectTabNamedInUrlHash() { let selectedTab = window.location.hash; $('.nav-link[href="' + selectedTab + '"]').trigger('click'); } jQuery(document).ready(function ($) { selectTabNamedInUrlHash(); }) </script> A sidebar anchor links to the page and adds a fragment (hash) to the href of the tab I want to navigate to (url