How to use Asp.Net Mvc ActionFilterAttribute for form authentication
摘要: 如何使用ASP.NET MVC Framework Preview 2 中ActionFilterAttribute属性设计Form用户验证
首先采用BaseController继承Controller以改写保护方法RedirectToAction为公有方法(用以在ActionFilterAttribute属性中使用),本例中扩展了两个属性RequireLoginAttribute 、 RequireRoleAttribute;在RequireLoginAttribute属性过滤中重定向为登录的用户到登录窗户、在 RequireRoleAttribute属性过滤中将非该用户角色的操作显示访问拒绝信息,具体代码如下:
阅读全文
posted @
2008-03-09 15:59 Bolik 阅读(2084) |
评论 (8) 编辑
当控件基类与页面基类名称相同时 CS0030
摘要: CS0030: Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'
asp代码如下: Inherits="Login" asp:Login 当我们在开发阶段使用时是不会有问题的,但是一旦将该页面预编译则会发生错误
我在这里找到了答案 其原因就是Inherits="Login" asp:Login 中的标记控件与页面基类名称相同,当我们在开发时编译与预编译不同造成
解决方法一是更改页面基类名程, 二是为页面基类增加命名空间 我采用的是增加命名空间的解决方法代码如下:
阅读全文
posted @
2006-09-27 10:24 Bolik 阅读(3029) |
评论 (8) 编辑