2018/05/08

Redirect the parent window when inside a frame

One of my project it's website has a frameset setting like the following:
<frameset border="0" frameborder="NO" framespacing="0" rows="110,*">
<frame index="" name="topFrame" noresize="" ome="" scrolling="NO" src="@Url.Action("AgentHeader", "Home")"><frame>
<frame name="main"></frame>
</frameset>

The "main" frame is the major workplace. However, if I set the logout method like the following, only the "main" frame will by redirected to login page. The "topFrame" is still there.
public ActionResult Logout()
{
    .....

    return RedirectToAction("Login", "Home");
}

How to redirect includes the whole page? (The parent window actually)
Here is what I got from the stack overflow and it works for me:
public ActionResult Logout()
{
    .....

    return Content("<html><script>window.top.location.href = 'your url';</script></html>");
}

Please share some other approaches with me if they work in this kind of situation.


Reference: Redirect the entire page from MVC3 Razor iFrame page to a different URL

No comments:

Post a Comment