便携式区域的不同视图引擎
我正在使用 ASP.NET MVC 2 和 MvcContrib 2 可移植区域。消费应用程序正在利用从标准 WebForm 视图引擎派生的 CustomWebFormViewEngine。我希望便携式区域“Foo”利用标准便携式区域嵌入式视图引擎。我该如何在不影响消费应用程序的情况下执行此操作?
消费应用程序正在这样做:
ViewEngines.Engines.Add(new CustomWebFormViewEngine()));
我不能在可移植区域中执行类似以下操作,因为这将从消费应用程序中清除 CustomWebFormViewEngine:
ViewEngines.Clear();
ViewEngines.Engines.Add(new WebFormViewEngine()));
那么我如何获取它,以便给定的可移植区域利用嵌入式视图引擎,但应用程序的其余部分继续使用 CustomWebFormViewEngine ?
I'm using ASP.NET MVC 2 and MvcContrib 2 portable areas. The consuming application is leveraging a CustomWebFormViewEngine which is derived from the standard WebForm view engine. I want the portable area "Foo" to utilize the standard portable area embedded view engine. How do I go about doing this, without affecting the consuming application?
The consuming app is doing this:
ViewEngines.Engines.Add(new CustomWebFormViewEngine()));
I can NOT do something like the following in the portable area, since that will clear off the CustomWebFormViewEngine from the consuming application:
ViewEngines.Clear();
ViewEngines.Engines.Add(new WebFormViewEngine()));
So how do I get it so that a given portable area leverages the embedded view engine, but the rest of the application continues to use the CustomWebFormViewEngine ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(抱歉,我没有足够的代表来发表评论)
您可以为不同的视图使用不同的文件扩展名,然后在视图引擎定义的 ViewLocationFormat 属性中指定吗?例如,您可以用“.cve”结束使用自定义视图引擎定义的所有视图,或者我是否误解了这个问题?
http://msdn.microsoft.com/en-us/library/dd492273.aspx
http://www.singingeels.com/Articles/Creating_a_Custom_View_Engine_in_ASPNET_MVC.aspx
(sorry I don't have enough rep to comment)
Can you use a different file extension for different views and then specify that in the ViewLocationFormat property of your view engine definition? For example, you can end all views that use the custom view engine definition with '.cve' Or have I misunderstood the question?
http://msdn.microsoft.com/en-us/library/dd492273.aspx
http://www.singingeels.com/Articles/Creating_a_Custom_View_Engine_in_ASPNET_MVC.aspx