'Asp.net Core Razor Pages, page handler not working
Can't call page handler methods. in razor page
<a asp-page="/CreateNew">Link1</a>
<a asp-page="/CreateNew" asp-page-handler="submit">Link1</a>
CreateNew.cshtml.cs:
public IActionResult OnGet()
{
return Page();
}
public IActionResult OnGetSubmit()
{
return Page();
}
Solution 1:[1]
If you use a razor page, you must put your file in the pages folder
Instead of Views Folder and your link will be as follows
<a asp-page="/PersonalPage/CreateNew">Link1</a>
And the startup file should be configured as follows
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
}
........
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

