ASP.NET MVC - CustomeAuthorize filter action using an external website for loggin in the user

此生再无相见时 提交于 2019-11-29 02:20:01

Use the RedirectResult similar to how you were using the RedirectToRouteResult before to replace the result in the filter context.

filterContext.Result = new RedirectResult("http://externalSite.com/login?returnUrl=" + filterContext.HttpContext.Request.RawUrl );

Let me see if I understand - you have an iFrame, and executing an action within this iFrame. You want to redirect to a parent page, not within that iFrame?

If so, just use Redirect(url) in your action.

You can add a judgement by jQuery on the login page.

$(function () {
        if (window != top) {
            top.location.href = location.href;
        }
    });   

OR

edit 'filterContext.Result' in action 'OnActionExecuting'

filterContext.Result = new ContentResult() { Content = "<script>top.window.location.href='/user/Login'</script>" };
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!