c# - 通过 cookie 控制对页面的访问

标签 c# asp.net cookies asp.net-mvc-4

我想通过 cookie 控制对我的应用的某些页面的访问。但我只想从一个地方进行协调。我想检查一下 Layout.cshtml I.E.这样所有使用此布局的页面都会自动执行。这样好吗?

编辑:此应用的安全性不是问题。

最佳答案

您违反了 MVC 的核心原则之一——永远不要将真正的逻辑放在 View 中

相反,您应该创建一个 ActionFilter。

您还应该弄清楚如何保护 cookie;您可能应该使用 ASP.Net 现有的成员(member)系统

关于c# - 通过 cookie 控制对页面的访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14059688/

相关文章:

c# - 无法访问 asp :TextBox tag from the C# file : the name 'txtUsername' does not exist in the current context

c# - 在流上生成 XOR 校验和的简单方法?

asp.net - MVC 是构建在 Web 表单之上的吗?

c# - 具有上限的线程安全集合

c# - 如何在 AX 查询服务中格式化 DateTime 比较值

c# - 模型或 Controller 中的 Asp.net mvc 下拉代码

asp.net - 当网站停止时,Oracle 数据提供程序会挂起 IIS 工作进程

PHP Cookie 用户系统 If 语句

ios - 使用 HTTPCookieStorage.shared 在 URLSessionConfiguration.background 中授权失败(cookes 未发送)

c# - HttpResponse : SetCookie, AppendCookie、Cookies.Add 之间的区别