How to switch home page depending on IFrame

I want to use IFrame in my ASP.Net MVC application, but I want to keep layout when inner pages are navigated using direct access (Search Engine).

How do I switch the main page based on whether the View was in an IFrame or a top-level window?

+1


source to share


2 answers


The ViewResult that you return in your controller The Action has a MasterName property. Ask your controller action to get a parameter that tells it if you have an IFrame or not, and then you can do



if (isInIFrame)
{
    ViewResult result = View();
    result.MasterName = "IFrameMaster";
    return result;
}

      

+2


source


One of the methods:



Place the content in a custom control. Write a lightweight view that wraps a custom control for the IFrame version and another for the top level version.

0


source







All Articles