系统用了一个Iframa 希望在没有登陆的时候跳转到登陆也,在基类里写了
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
base.OnActionExecuting(filterContext);
if (IsLogin == false)
{
string url = Domain+ "/Auth/Login";
url = string.Format("parent.window.location.href = '{0}'", url);
ContentResult Content = new ContentResult();
Content.Content = string.Format("<script type='text/javascript'>{0}</script>", url);
Content.ContentType = "application/javascript";
filterContext.Result = Content;// Redirect(url);
return;
}
}
前段页面显示了这段文字,没有执行这段js
试试把 application/javascript
改为 text/html
改成这样真的可以了,谢谢