-
Notifications
You must be signed in to change notification settings - Fork 0
Razor Pages Examples
Stephan van Leeuwen edited this page May 3, 2021
·
9 revisions
/Pages/Index.cshtml
@page
<h1>Index</h1>
Usage
@Url.Pages().Index() // => "/"
/Pages/Details.cshtml
@page "{id:int}"
<h1>Detail</h1>
Usage
@Url.Pages().Detail(id: 2) // => "/Detail/2"
/Pages/Model.cshtml
@page
@model AspNetCoreSamplePages.Model
<h1>Model</h1>
/Pages/Model.cshtml.cs
namespace AspNetCoreSamplePages
{
public class Model : PageModel
{
public void OnGet(int page)
{
//...
}
}
}
Usage
@Url.Pages().Model(page: 2) // => "/Model?page=2"
/Pages/Index.cshtml
@page
@model AspNetCoreSamplePages.IndexModel
<h1>Handler</h1>
/Pages/Index.cshtml.cs
namespace AspNetCoreSamplePages
{
public class IndexModel : PageModel
{
public void OnGet()
{
}
public void OnGetSpecific()
{
}
}
}
Usage
@Url.Pages().IndexHandlers.Specific() // => "/?handler=Specific"
/Areas/Admin/Pages/Index.cshtml
@page
<h1>Admin Area</h1>
Usage
@Url.AdminPages().Index() // => "/Admin/"