I have an Asp.Net Core Razor Pages project, I have implemented a series of razor pages, some of these but at the moment I would like to "disable / remove them" so that they are not usable by users, as a sort of feature flag. Is it possible to do this kind of thing with ex:
[Disabled]
public abstract class MyPageModel : PageModel
{
// My code
}
attributes or in the Startup.cs or do I have to remove them from the project? Thanks
Removing the @page directive will display as the same as return NotFound(). However, you can specify this in the code-behind file. This would allow you to redirect the user to a specific page, e.g. one's homepage
public abstract class MyPageModel : PageModel
{
public IActionResult OnGet()
{
return NotFound(); //This is one option or
return RedirectToPage("Index"); //redirect to fx. homepage
}
}