如何制作像 superuser.com 上的那样的测试版访问页面?

发布于 2024-08-02 07:17:47 字数 203 浏览 5 评论 0原文

我正在使用 ASP.Net MVC,我希望建立一个可通过互联网访问的网站,但目前仅限少数人访问。我想做的事情基本上与带有密码的 beta 访问页面完全相同,就像他们在 stackoverflow、serverfault 和超级用户上所做的那样。

我不仅仅想在家庭控制器中进行检查和重定向,我希望它始终去那里,无论使用什么 url。

有人知道他们是怎么做到的吗?

I'm working with ASP.Net MVC and I would like to make a web site accesible via the internet, but only to a select few people right now. I want to do something basically exactly like the beta access page with password just like they did on stackoverflow, serverfault, and superuser.

I don't just want to check and redirect in the home controller, I want it to always go there no matter what url is used.

Anyone know how they do it?

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

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

发布评论

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

评论(3

三五鸿雁 2024-08-09 07:17:47

我对 MVC 不太了解,但这可能意味着创建一个基本控制器并覆盖 OnActionExecuting 或 OnAuthorization。

I don't know enough about MVC in particular, but it would probably mean creating a base controller and overriding OnActionExecuting or OnAuthorization.

那片花海 2024-08-09 07:17:47

我将创建一个扩展 AuthorizeAttribute 的自定义过滤器。这样您就可以将其放在您想要的控制器/操作上,并轻松地将其删除。由于它本质上是一个装饰器,因此您也可以很好地遵守开/闭原则

如果您覆盖AuthorizeCore,您可以检查会话/cookie/任何登录信息,如果通过,也运行基本AuthorizeCore

I'd create a custom filter that extended AuthorizeAttribute. That way you can put it on the controllers/actions you wanted, and remove it easily enough. Since it's essentially a decorator, you would be playing nice with the Open/Closed principle too.

If you override AuthorizeCore you can check session/cookie/whatever for the login and if that passes, run the base AuthorizeCore too.

柠檬心 2024-08-09 07:17:47

最简单的方法是将一些内容放入用户会话中。在母版页或 http 处理程序中运行检查以查看此会话是否正确。如果没有重定向到密码捕获页面。提供密码后,然后设置会话变量...wa la 他们所在的位置。

如果您想记住它们,那么还可以删除一个 cookie 并将其添加到您的支票中。

The easy way is to put something in the users session. Run a check either on the master page or in an http handler to see if this session is correct or not. If not redirect to the password capture page. When the password is provided then set the session variable...wa la they are in.

If you want to remember them then also drop a cookie and add that to your check as well.

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