I have some controller action that can be accessed via an iframe that is launched in some view. This controller action can also be accessed via the website in it's normal fashion. I have implemented the controller so that when the ?iframe=true
parameter is in the URL it behaves differently.
So the controller action looks like:
public ActionResult Index(bool? iframe=null){
//...some controller logic...
if(iframe==true){
ViewBag.InIFrame = true;
}
return View("Index", model)
}
Then the View will load a different layout depending on whether the ViewBag.InIFrame
is set.
But now I would need to do this for every controller action where it is feasible that the user could navigate to from within the iframe. Is there a better way I could do this? I thought of using a session variable that is set when the user is navigated to the first expected page within the iframe, but if the user navigates to the some pages of the site in a different tab (not in an iframe) it will load the layout for when we are in an iframe.
Any ideas or should I just suck it up and make each controller action do the same check for iframe
being a supplied parameter?