Reputation: 10827
I want to use an IFrame in my ASP.Net MVC application, yet I want to retain the layout when the internal pages are navigated via direct access (Search Engine).
How would I switch the master page based on whether the View was in an IFrame, or a top level window?
Upvotes: 1
Views: 1345
Reputation: 8986
The ViewResult you return in your controller Action has a MasterName property. Have your controller action receive a parameter that tells it whether you're in an IFrame or not and then you can do
if (isInIFrame)
{
ViewResult result = View();
result.MasterName = "IFrameMaster";
return result;
}
Upvotes: 2
Reputation: 126547
One way:
Put the content in a user control. Write a lightweight view which wraps the user control for the IFrame version, and another for the top-level version.
Upvotes: 0