开发者

Move baseclasses for MasterPage from MVC2 to MVC3

I am working on moving an application from MVC2 ASPX to MVC3 Razor, and is quite stuck moving a baseclass for more MasterPages in old MVC2 application.

The baseclass is used for automate include of css and js on pages in order to ease quickfix and debugging when developing application in local environment, but when running application in production environment it has to update and include single minimized css and js files delivered from a external CDN.

The code needs to know about the View file eg. "~/views/home/index.chtml" and/or the Layout file eg. "~/Views/Defaul开发者_开发问答tNoLogon.Master" in order to include and handle css and js files correct.

I tried to implement own baseclass using the pageBaseType in Razor part of web.config, but it seems like it is executed both for View and Layout file, and I could not find a execution point where information about both View and Layout file is present. I also tried to implement the file logic using a HtmlHelper, but I can only access information about the View file and miss information for Layout file for View.

I don't want this kind of code to be implemented in Route, Controller or ViewModel since it should be related directly to generation of Views.

Any ideas how to get information about View and Layout files in MVC3 Razor app?


Well, never mind my question.

I redesigned my logic for automatic rendering of js and css files, which actually is more simple and works better. My Mvc3 Razor app is now capable to take all js and css files for a view (including css and js for all layoutpages) and render them into single minified files.

Works like a charm, and I guess it's more future proof than my old solution, unless Guthrie make fundamental changes in layoutpages and Html helpers in Mvc4 or later.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜