We are currently hosting a asp.net mvc 2 website in IIS 6. In this application we override the 'Create Controler' method and configure a custom view engine. This engine specifies the location of the views depending on the url format. for example; if a user lands on www.asite.com/test/1.0/index.aspx the view engine tells mvc to look for index.aspx in the 'sitedirectory/test/1.0/views/pages/' directory;
string versionDirectory = String.Format("~/{0}/{1}", offerCode, version.ToString("#0.0000"));
ViewLocationFormats = new[]
{
versionDirectory + "/Views/Pages/{0}.aspx",
versionDirectory + "/Views/Pages/{0}.ascx",
"~/Views/Pages/{0}.aspx",
"~/Views/Pages/{0}.ascx",
"~/Shared/Views/{0}.aspx",
"~/Shared/Views/{0}.ascx"
};
MasterLocationFormats = new[]
{
versionDirectory + "/Views/Layouts/{0}.master",
"~/Views/Layouts/{0}.master"
};
PartialViewLocationFormats = ViewLocationFormats;
The Issue that we are having is that when two or more users land on the site at roughly the same time, the views that get loaded can get switched around. However the data that is shown for those views is correct.
does anyone have any ideas why this would be happening?
This is a (little) known issue - there is a problem with caching going on.
Take a look at this post: http://www.hanselman.com/blog/ABetterASPNETMVCMobileDeviceCapabilitiesViewEngine.aspx
And go through the comments.
I ended up implementing owe view engine that derives from IViewEngine directly and uses WebFormsViewEngine internally.