#region 3.2 重定向方法 根据Action方法特性 +ActionResult Redirect(string url, ActionDescriptor action)
/// <summary>
/// 重定向方法 有两种情况:如果是Ajax请求,则返回 Json字符串;如果是普通请求,则 返回重定向命令
/// </summary>
/// <returns></returns>
public ActionResult Redirect(string url, ActionDescriptor action)
{
//如果Ajax请求没有权限,就返回 Json消息
//action.IsDefined判断有没有个标记AjaxRequestAttribute
if (action.IsDefined(typeof(AjaxRequestAttribute), false)//如果ajax请求没有权限,就返回json字符串消息 或者 返回重定向命令
|| action.ControllerDescriptor.IsDefined(typeof(AjaxRequestAttribute), false))
{
return RedirectAjax("nologin", "您没有登陆或没有权限访问此页面~~", null, url);
}
else//如果 超链接或表单 没有权限访问,则返回 302重定向命令
{
return new RedirectResult(url);
}
}