How to use multiple view engines in ASP.NET MVC application

前端 未结 2 924
萌比男神i
萌比男神i 2020-12-19 22:21

I\'d like to use two view engines in my asp.net mvc web application. The first one is the Brail view engine from MVCContrib project, and another one is my custom view engine

相关标签:
2条回答
  • 2020-12-19 22:58

    I believe you can change your view engine in the controller. So I would extend your controller to select a view engine by extension.

    0 讨论(0)
  • 2020-12-19 23:02

    Like this.

    EDIT: If your custom ViewEngine isn't handling *.json, you might well have a bug in your view engine. The easiest way to deal with this is to subtype VirtualPathProviderViewEngine and set the MasterLocationFormats, ViewLocationFormats, and PartialViewLocationFormats in the constructor. See the source code for WebFormViewEngine for a very simple example. This way the framework code does all the lifting for you.

    0 讨论(0)
提交回复
热议问题