How to use Razor Pages hierarchy with multiple route parameters
By Tan Lee Published on Feb 18, 2024 3.36K
This post shows you how to use multiple routing attributes in .net core razor pages
For example:
Pages/Blogs/id
@page "/Blogs/{id:int}"
and OnGetAsync
public async Task<IActionResult> OnGetAsync(int id){ }
Pages/Blogs/Items/itemid/Posts/id
@page "/Blogs/Items/{itemid:int}/Posts/{id:int}"
And you could get id by using
public async Task<IActionResult> OnGetAsync(int id, int itemid){ }
- Implement security headers for an ASP.NET Core
- How to add security headers to an ASP.NET Core Application
- How to Initialize TagHelpers in ASP.NET Core with Shared Data
- Boost Your ASP.NET Core Website Performance with .NET Profiler
- The name 'Session' does not exist in the current context
- Implementing Two-Factor Authentication with Google Authenticator in ASP.NET Core
- How to securely reverse-proxy ASP.NET Core
- How to Retrieve Client IP in ASP.NET Core Behind a Reverse Proxy
Categories
Popular Posts
Structured Data using FoxLearn.JsonLd
Jun 20, 2025
Implement security headers for an ASP.NET Core
Jun 24, 2025
Modular Admin Template
Nov 14, 2024
10 Common Mistakes ASP.NET Developers Should Avoid
Dec 16, 2024
Simple Responsive Login Page
Nov 11, 2024