Skip to main content

All Questions

4 votes
2 answers
6k views

ASP.NET Core Razor Pages Model State Is Not Valid & Model data is empty

I am new to ASP.NET core razor pages & while practising I am facing a problem related to ViewModel Binding in Core2.1 Razor Pages. When I post form data then it shows ModelState is invalid with ...
panky sharma's user avatar
  • 2,119
0 votes
0 answers
508 views

Checking the ModelState OnPost of only the visible form's properties in razor pages

I created a razor page that has the following properties: [BindProperty] public CustomerViewModel Customer { get; set; } [BindProperty] public CustomerContactViewModel Contact { get; set; } Within ...
Blake Rivell's user avatar
  • 13.6k
0 votes
1 answer
2k views

Making an AJAX request to a controller or page model with Razor Pages

With the addition of Razor Pages as an option for .net core I am a bit confused. I am aware that handlers can be used to call multiple actions of the same HTTP type. But what if I want to create an ...
Blake Rivell's user avatar
  • 13.6k
3 votes
0 answers
2k views

Getting Client-side validation to work

Situation: project created by dotnet new webapp My Razor Pages page is working with server side validation, that is, ModelState is returning the correct value accordingly. According to this, am I ...
Old Geezer's user avatar
  • 15.8k
1 vote
0 answers
206 views

How to render a specific view from a different PageModel file

From page1.cshtml.cs, how do I render the contents of page2.cshtml? I am not looking for redirection as I don't want the url address to change.
Old Geezer's user avatar
  • 15.8k
3 votes
1 answer
3k views

How to exclude layout?

My ASP.NET Core web project has the usual shared layout file. How do I exclude the use of layout for a specific page?
Old Geezer's user avatar
  • 15.8k
1 vote
1 answer
459 views

How to use functions in asp-for attribute or @Html.EditorFor or @Html.TextBoxFor

I am developing MVC website in .Net Core 2.0. In this, I want ViewModel binding but, my ViewModel is of IEnumeration Type. When I want to use functions to in the tag i.e. @Html.EditorFor(Model....
Siddharth692's user avatar
0 votes
1 answer
770 views

Razor pages custom routes

I am trying to get following routes so, i have the GlobalTemplatePageRouteModelConvention. I used int? constraint to distinguish /1 from /ListJson handler but I am not happy with it, it is needlessly ...
subcoder's user avatar
  • 654
7 votes
5 answers
17k views

Inserting html tags between C# block code in cshtml file

I want to use html tags between C# block code, I've tried it but I got errors. How can I insert html tags between C# block code in cshtml file? The error is: only assignment call increment ...
x19's user avatar
  • 8,663
1 vote
1 answer
3k views

How to load partial razor page into razor view

I am trying to replace my view components with razor pages but it seems that it's not possible to load a partial razor page because a model is expected to be passed yet it is my understanding that the ...
OjM's user avatar
  • 1,079
5 votes
4 answers
7k views

Routing using ASPNET Core 2.0 RazorPages

I've done quite some ASP.NET API programming over the years, but am very new to .NET Core and RazorPages. I cannot seem to get routing working properly. For example, I have an Index page. The OnGet ...
JasonX's user avatar
  • 533
2 votes
2 answers
3k views

Override razor views in asp.net core razor pages

In asp.net core mvc, I had multiple locations specified for the views. so, if view was missing in one location, it gets fetched from the other location. I have a CMS with asp.net core mvc where ...
eadam's user avatar
  • 25.2k