Incorrect page loading in MVC

送分小仙女□ 提交于 2019-12-11 14:26:39

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/4993721/incorrect-page-loading-in-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!