Relative Content

Tag Archive for asp.net-corerazor-pages

Handler is calling _Layout page and Get() method

When calling a handler from cshtml page (using Razor project) why it is doing full page refresh by going to public void OnGet() method and then it go to public IActionResult OnPostExportCSV(int id)? I was thinking by callling the hadler ExportCSV it will directly goto call OnPostExportCSV(int id)

Asp.net core razor pages BindProperty collections List not Working

My plan is that I fill a list of data in OnGet and after sending it to the html page, I checkMark some lines and Fill some input on table, and finally it is posted to the server. But in OnPost, the collection is empty and does not return anything:
But in onpost, the collection is empty and does not return anything:

Html is displayed as a plain text in Asp.Net Core Razor pages

I am working on Asp.Net Core 6.0 MVC Razor pages. On the Login.cshtml page, I want to show the following error message when the user tries to login with in invalid credential: Invalid: User Name and/or Password. The problem is this message is displayed as a text instead of an html with the “User Name” and “Password” in bold. The following is my C# code in Login.cshtml.cs

A value from my form in my index doesn’t get passed to the backend

I am making asp.net core program with razor pages where I want to send data from my index.cshtml page to the indes.cshtml.cs, I am using the asp-for method in my form to pass the value to a variable in the .cs file but the value never gets passed. this is what the code looks like.