项目使用的是mvc1.0 一个类继承Controller实现抽象方法OnActionExecuting. 大家帮我看下,谢谢。 protected override void OnActionExecuting(ActionExecutingContext filterContext)
{ string[] arr = Request.Url.Host.Split('/');
string newEventName = arr[0].ToLower(); //if (newEventName == "manage")
//{
// Response.Redirect("manage");
//}
if (!filterContext.HttpContext.User.Identity.IsAuthenticated || Session["user"] == null)
{
//use the current url for the redirect
string redirectOnSuccess = filterContext.HttpContext.Request.Url.AbsolutePath; //send them off to the login page
string redirectUrl = string.Format("?ReturnUrl={0}", redirectOnSuccess);
string loginUrl = FormsAuthentication.LoginUrl + redirectUrl;
filterContext.HttpContext.Response.Redirect(loginUrl, true); }#if DEBUG
this.EventList = new EventRepository().GetEventList(1);
#else
if (this.CurrentCompany != null)
{
this.EventList = new EventRepository().GetEventList(this.CurrentCompany.id);
}
#endif if (this.EventList != null && this.EventList.Count > 0)
{ if (this.CurrentEvent == null ||
newEventName != this.CurrentEvent.eventName.ToLower())
{
this.CurrentEvent = this.EventList.Where(e => e.eventName.ToLower() == newEventName).SingleOrDefault(); if (this.CurrentEvent == null)
{
this.CurrentEvent = this.EventList[0];
_isRedirectSubDomain = true;
//filterContext.Result = JavaScript("Banner");
}
} ViewData["EventList"] = new SelectList(this.EventList, "id", "eventname", this.CurrentEvent.id); base.OnActionExecuting(filterContext);
}
}
{ string[] arr = Request.Url.Host.Split('/');
string newEventName = arr[0].ToLower(); //if (newEventName == "manage")
//{
// Response.Redirect("manage");
//}
if (!filterContext.HttpContext.User.Identity.IsAuthenticated || Session["user"] == null)
{
//use the current url for the redirect
string redirectOnSuccess = filterContext.HttpContext.Request.Url.AbsolutePath; //send them off to the login page
string redirectUrl = string.Format("?ReturnUrl={0}", redirectOnSuccess);
string loginUrl = FormsAuthentication.LoginUrl + redirectUrl;
filterContext.HttpContext.Response.Redirect(loginUrl, true); }#if DEBUG
this.EventList = new EventRepository().GetEventList(1);
#else
if (this.CurrentCompany != null)
{
this.EventList = new EventRepository().GetEventList(this.CurrentCompany.id);
}
#endif if (this.EventList != null && this.EventList.Count > 0)
{ if (this.CurrentEvent == null ||
newEventName != this.CurrentEvent.eventName.ToLower())
{
this.CurrentEvent = this.EventList.Where(e => e.eventName.ToLower() == newEventName).SingleOrDefault(); if (this.CurrentEvent == null)
{
this.CurrentEvent = this.EventList[0];
_isRedirectSubDomain = true;
//filterContext.Result = JavaScript("Banner");
}
} ViewData["EventList"] = new SelectList(this.EventList, "id", "eventname", this.CurrentEvent.id); base.OnActionExecuting(filterContext);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货