I am using a razor page and want to get the value from the path. What is the correct way to do this using the razor page or do I have to parse the Http URL?
[HttpGet("{id}")]
public void OnGet(string id)
{
if(id == null)
{
}
else
{
}
}
CodePudding user response:
Change the razor syntax @page
in your .cshtml
file like below:
@page "{id?}"
[HttpGet("{id}")]
cannot be applied to Razor Pages, remove it in your .cshtml.cs
file.
Reference: