我的需求是:
1. http://username.xx.xxxxx.com/index.htm
2. http://xx.xxxxx.com/username.htm
第一个是vip会员的url,第二个是普通会员的url
我现在想在拦截器里写一个方法,用以判断这个会员是不是vip,防止一些不是vip的会员生成的是vip会员的主页。using System.Web.Mvc;
using Aqioo.Extensions;
using Aqioo.Results;
using Aqioo.Modules.Consult.Services;
namespace Aqioo.Modules.Consult.Filters
{
public class VipFilter : IActionFilter//FilterAttribute,
{
private readonly IConsultService consultService; public VipFilter(IConsultService consultService)
{
this.consultService = consultService;
} #region IActionFilter Members public void OnActionExecuted(ActionExecutedContext filterContext)
{
} public void OnActionExecuting(ActionExecutingContext filterContext)
{
string userName = filterContext.ActionParameters["userName"].ToString();
if (!string.IsNullOrEmpty(userName))
{
var consult = consultService.GetConsultByUser(userName);
}
} #endregion }
}这是拦截器的代码。。
我应该怎样 来做呢?
1. http://username.xx.xxxxx.com/index.htm
2. http://xx.xxxxx.com/username.htm
第一个是vip会员的url,第二个是普通会员的url
我现在想在拦截器里写一个方法,用以判断这个会员是不是vip,防止一些不是vip的会员生成的是vip会员的主页。using System.Web.Mvc;
using Aqioo.Extensions;
using Aqioo.Results;
using Aqioo.Modules.Consult.Services;
namespace Aqioo.Modules.Consult.Filters
{
public class VipFilter : IActionFilter//FilterAttribute,
{
private readonly IConsultService consultService; public VipFilter(IConsultService consultService)
{
this.consultService = consultService;
} #region IActionFilter Members public void OnActionExecuted(ActionExecutedContext filterContext)
{
} public void OnActionExecuting(ActionExecutingContext filterContext)
{
string userName = filterContext.ActionParameters["userName"].ToString();
if (!string.IsNullOrEmpty(userName))
{
var consult = consultService.GetConsultByUser(userName);
}
} #endregion }
}这是拦截器的代码。。
我应该怎样 来做呢?
解决方案 »
- 关于remoting配置问题
- label等控件如何用点替换过长内容
- asp.net配置与布局问题
- 在数据库里OLE对象里储存图片.如何显示出来!
- IE历史纪录及缓存问题
- listview中的edititemtemplate问题
- 分析器错误!我搜索了很多的帖子!但实在是不行!在我本地的机器上可以!但在internet网上就不行了!
- 请问在ado.net中如何取得SQL存储过程中用return返回的值?在线揭贴
- link button配合Repeater製作分頁 link button只能實現第一次的 "下一頁" 和 "上一頁"功能
- 想把页面表单内容导出为word文档保存起来,大家可否提供点思路?(分不够可再开帖放分)
- request.form取值
- GridView导出excel无数据【期待。。。。】
{
public RoleAttribute(RoleTypeEnum roleType)
{
this.RoleType = roleType;
}
public RoleTypeEnum RoleType { get; set; } public void OnAuthorization(AuthorizationContext filterContext)
{
HttpContextBase b = filterContext.RequestContext.HttpContext;
UserModel model = b.Session["User"] as UserModel;
if (model != null)
{
if (model.RoleType != this.RoleType)
{
filterContext.Result = new RedirectToRouteResult("default", new RouteValueDictionary(new { controller = "Shared", action = "Error" }));
}
}
}
}
然后在controller或者action上面打上相应标记就好了中[AcceptVerbs(HttpVerbs.Get)]
[Role(RoleTypeEnum.Admin)]
public ActionResult Index(int? id)
{
}