Questions tagged [razor-pages]

Apply to questions related to the Razor Pages Framework, which is a feature of ASP.NET Core starting in ASP.NET Core version 2.0.

Note that Razor Pages is separate from Razor, which is a templating syntax used in Views in both ASP.NET and ASP.NET Core. You should only apply the Razor Pages tag to questions that are specifically about the Razor Pages framework, not just questions about Razor or ASP.NET (Core) Views.

4190 questions
241
votes
7 answers

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

In VS 2017, I created a new ASP.NET Core Web Application. On the second page of the wizard, I chose Web Application, and for Authentication, I chose "Individual User Accounts". Now, I'm trying to find the Pages associated with /Account/Register and…
Bob.at.Indigo.Health
  • 11,023
  • 13
  • 64
  • 111
126
votes
9 answers

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

According to the documentation, Razor views should, by default, recompile on change on local environments for ASP.NET Core 3.0. However, my project doesn't do this locally. If I change a view and refresh when I'm debugging locally, the change is not…
tarun713
  • 2,177
  • 3
  • 17
  • 31
91
votes
4 answers

ASP.NET Core Razor pages vs Full MVC Core

There has been a question at SO Why is Razor Pages the recommended approach to create a Web UI in Asp.net Core 2.0? where Steve Smith has kindly explained the benefits of using Razor Pages over full MVC from the perspective of having less files.…
Ivan Zaruba
  • 4,236
  • 5
  • 20
  • 29
82
votes
4 answers

Why is Razor Pages the recommended approach to create a Web UI in Asp.net Core?

Learning new things needs an investment of time, space and energy. I am currently learning Asp.Net Core MVC 2.0. This ASP.NET Core tutorials overview states: Razor Pages is the recommended approach to create a Web UI with ASP.NET Core This…
54
votes
10 answers

This version of Microsoft.AspNetCore.All is only compatible with the netcoreapp2.1 target framework

When I try to publish my application to the web server after upgrading to .NET Core 2.1 from 2.0, I get this message: "This version of Microsoft.AspNetCore.All is only compatible with the netcoreapp2.1 target framework. Please target netcoreapp2.1…
Jim S
  • 1,069
  • 3
  • 10
  • 17
51
votes
5 answers

How to redirect on ASP.Net Core Razor Pages

I am using the new Razor Pages in ASP.Net core 2 Now I need to redirect I tried this, but the page does not redirect: public class IndexModel : PageModel { public void OnGet() { string url =…
Tony
  • 16,527
  • 15
  • 80
  • 134
48
votes
8 answers

.Net Core 3.0 JsonSerializer populate existing object

I'm preparing a migration from ASP.NET Core 2.2 to 3.0. As I don't use more advanced JSON features (but maybe one as described below), and 3.0 now comes with a built-in namespace/classes for JSON, System.Text.Json, I decided to see if I could drop…
Asons
  • 84,923
  • 12
  • 110
  • 165
45
votes
7 answers

Can Razor Class Library pack static files (js, css etc) too?

Maybe duplicate of this already, but since that post does not have any answer, I am posting this question. The new Razor Class Library is awesome, but it cannot pack libraries files (like jQuery, shared CSS). Can I somehow reuse the CSS across…
Luke Vo
  • 17,859
  • 21
  • 105
  • 181
36
votes
4 answers

Setting a startup page in Blazor

The startup page in my Blazor application is Index.cshtml. I'd like to change the startup page to the homepage, namely my Home.cshtml. I'm using vs2019, ASPNET CORE Blazor (0.9.0-preview3-19154-020). Blazor Serverside has routing in the…
PeteBal
  • 361
  • 1
  • 3
  • 3
36
votes
1 answer

400 Bad Request when POST-ing to Razor Page

My page has... @page "{candidateId:int}" ... and @Html.AntiForgeryToken() Model has... public void OnGet(int candidateId) { } public void OnPost(int candidateId) { } GET works fine. Here is my AJAX request.. $.ajax({ type: "POST", url:…
Ian Warburton
  • 15,170
  • 23
  • 107
  • 189
33
votes
1 answer

When to use LocalRedirect vs RedirectToPage

With ASP.Net Core 2.1 Razor Pages, what is the best practice on using LocalRedirect() vs. RedirectToPage()? It seems they can be used interchangeably when redirecting to a page within the current website. Is there an advantage to one over the…
user6089428
30
votes
4 answers

ASP.NET Core 2.1 Identity: How to remove the Default UI razor pages?

Expanding the answer in this question: Change routing in ASP.NET Core Identity UI? Javier recommends one of the following options when wanting to customise the URLs: Use the scaffolding element of the Default UI and make all necessary …
Daniel Congrove
  • 3,519
  • 2
  • 35
  • 59
29
votes
9 answers

There are no scaffolders supported for this item Visual Studio 2019

I'm using Visual Studio 2019 version 16.0.4, and I tried to create a view or a partial one on asp.net core 2.1 (in views folder) but I get an error There are no scaffolders supported for this item Then I realized this problem happens when you…
24
votes
4 answers

Render a Razor Page to string

Problem: I need to render a Razor Page partial to a string. Why I want this: I want to create a controller action that responds with JSON containing a partial view and other optional parameters. Attempts: I am familiar with the following example…
OronDF343
  • 528
  • 1
  • 3
  • 14
20
votes
5 answers

How to disable "Attempting to reconnect to the server" message on ASP.NET Core producton server

I have an ASP.NET Core 3.1 C# razor pages application that also uses some Blazor-serverside razor components. I have published it to IIS on Windows 2008 R2 Server. But when browsing the site in Chrome on one andorid mobile phone a message appears…
1
2 3
99 100