/// <summary> /// 授权失败返回处理 /// </summary> /// <param name="vret"></param> /// <returns></returns> public virtual ActionResult AuthorizeVerifyFail(Result vret) { //调用默认授权失败返回消息处理 string url = WebExtention.GetCurrentDomainUrl() + WebExtention.UrlEncode(HttpContext.Current.Request.RawUrl.ToString()); //判断是否为Ajax请求 if (WebExtention.IsAjax()) { if (string.IsNullOrEmpty(vret.Message)) { vret.Message = "登录超时,请重新登录!"; } //Ajax请求返回json数据 Result ret = new Result(vret.Message, ResultTypes.UnAuthorize); JsonResult result = new JsonResult(); result.Data = ret; return((ActionResult)result); } else { //没有登录跳转请问登录 RouteValueDictionary route = new RouteValueDictionary(); route.Add("action", "Index"); route.Add("controller", "OAuth"); route.Add("return_url", url); RedirectToRouteResult result = new RedirectToRouteResult(route); return(result); } }
/// <summary> /// 返回错误信息 /// </summary> /// <param name="Message">错误消息</param> /// <param name="ViewName">页面名字</param> /// <returns></returns> private ActionResult GetErrorResult(string Message, string ViewName = "Error") { if (WebExtention.IsAjax())//判断是否是ajax请求 { JsonResult result = new JsonResult(); result.Data = new { Success = false, Status = 500, Message = Message }; return((ActionResult)result); } else { ViewResult view = new ViewResult(); view.ViewName = ViewName; view.ViewBag.Message = Message; return((ActionResult)view); } }