1

I come from a background in ASP.NET MVC 5 on .NET 4.8.

I've been trying to wrap my head around the new razor pages, and can't seem to get routing to work, or understand it, even.

I don't want to use the @page directive, because I want more flexibility over how things are routed. (I've also found it doesn't even work as I expect it to from the documentation, so yay for an entirely new stack that's vastly different from the old one)

Let's say for instance we use the default ASP.NET Core 6 application and replace Index.cshtml with Index.razor. So far I've found this to be an effort in futility. I also think this is the wrong way to go about it, or I'm missing something intrinsic to how .razor files and routing are intended to work.

I could create a .cshtml that immediately renders the .razor file, but that seems like it's missing the point.

I've added this to my Program.cs:

builder.Services.AddServerSideBlazor();

All I really want is the ability to have the functionality in composable razor components.

I like the move toward dependency injection due to its separation of concerns; however it also makes it quite difficult to find the exact module you're looking to plug into the service stack.

Eventually I want to use a MapDynamicControllerRoute due to the tenancy needs I have in the project. This is why I need more than just a @page directive.

It's frustrating being shot back to the state of I don't know what I don't know and be unable to ask google the right questions. Right now I'm stuck at it no work.

3
  • The @page directives are usually used with the default <Router> component. Did you consider writing your own router? I guess you could tailor it exactly to your needs.
    – pschill
    Jan 30 at 16:05
  • This is one of those cases where I don't know what I don't know. How's this router work? Jan 30 at 22:38
  • I never built one myself, but this github repo contains an example.
    – pschill
    Jan 31 at 19:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.