ASP.NET核心禁用/删除特定的剃刀页

发布于 2025-01-27 10:33:42 字数 241 浏览 1 评论 0原文

我有一个ASP.NET Core Razor页面项目,我已经实施了一系列剃须刀页面,其中一些页面,但目前我想“禁用 /删除它们”,以便用户不使用它们,作为一种功能标志。是否可以使用ex:属性或在启动中进行此类操作

[Disabled]
public abstract class MyPageModel : PageModel
{ 
    // My code
}

,或者我必须从项目中删除它们? 谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Spring初心 2025-02-03 10:33:42

删除@page指令将显示与返回notfound()相同。但是,您可以在代码范围文件中指定此内容。这将使您可以将用户重定向到特定页面,例如一个人的主页

public abstract class MyPageModel : PageModel
{ 
    public IActionResult OnGet()
    {
       return NotFound();  //This is one option or 
       return RedirectToPage("Index");   //redirect to fx. homepage    
    }
}

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    
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文