开发者

Controlling Razor views programmatically?

开发者 https://www.devze.com 2023-02-14 06:09 出处:网络
Is is possible to programmatically control Razor views? Can I reach the different RenderSection parts or change the Layout defin开发者_JAVA技巧ition in code?

Is is possible to programmatically control Razor views? Can I reach the different RenderSection parts or change the Layout defin开发者_JAVA技巧ition in code?

I'm looking into possibilities to use Razor syntax in the presentation layer of a CMS application. Might Spark be a better choice because of it's (parseable) XML syntax?


Take a look at http://razorengine.codeplex.com and http://tqcblog.com/2011/01/23/precompiled-razor-for-shared-views-and-mono/ - you can convert razor views to c# code and set the views to use a custom base class that has whatever additional functionality you need.

You may also be able do something with the viewstart file - although set up as a razor view, it is effectively custom code that modifies the settings of all views, including the layout.

0

精彩评论

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