Reputation: 7119
I have a system which contains a number of forms built in ASP.net MVC which is designed to be used across multiple, 3rd party websites via an iframe. Each 3rd party site is assigned a unique URL e.g.
http://iframedomain.com/iframe/f9a14f53-0528-4ad1-b451-8895360e57e4
The controller checks the Guid is valid, and if there is a path to a custom css file assigned to it. If there is then this custom css is stored in a Session variable - the css files all reside in subfolders within the Content/Style of the domain the iframe is hosted on. Then the user is redirected to the correct form.
Each of the form controllers inherits from a common controller, within which there is an override on OnActionExecuting, which passes the custom css into the VIewBag:
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (Session["iFrameCSS"] != null)
{
ViewBag.iFrameCSS = Session["iFrameCSS"];
}
if (Session["JQueryTheme"] != null)
{
ViewBag.JQueryTheme = Session["JQueryTheme"];
}
base.OnActionExecuting(filterContext);
}
The layout file then checks for this and imports the correct CSS file:
@if (ViewBag.iFrameCSS != null)
{
string cssFile = ViewBag.iFrameCSS.ToString();
if (cssFile.StartsWith("http", StringComparison.CurrentCultureIgnoreCase))
{
<link rel="stylesheet" href="@cssFile" type="text/css" media="screen, projection" />
}
else
{
<link rel="stylesheet" href="@Url.Content("~/Content/style/" + cssFile + ".css")" type="text/css" media="screen, projection" />
}
}
else
{
<link rel="stylesheet" href="no-custom-css-file.css" type="text/css" media="screen, projection" />
}
This all works fine in all browsers except IE (tested in 7/8/9) where the link to the css file is just not there and the default css file is used. I have debugged locally and see different results in IE where the Session is working fine and the ViewBag variables are definitely being set however this is simply not working on the live server. I can't see what is wrong here? I've tested on 4 different machines (4 different people with very different setups, all with the same result)
Upvotes: 1
Views: 499
Reputation: 31862
Maybe this is an issue with cross domain session cookies. Setting P3P headers should resolve it. There is a lot of questions about P3P on SO.
If iframe is in different domain than parent, they are 3rd party cookies and there are some restrictions for setting them by default in Internet Explorer and Safari.
Macros solved his problem by using cookieless sessions.
Upvotes: 1