viewengine

Overriding MVC 4.0 ViewEngine

不问归期 提交于 2019-12-11 04:59:10
问题 I want to have different views in different directories (NOT AREAS!) so that when the URL contains a certain string , the viewEngine will result serving the another view (same name) from a different directory. The Code is here: public class CheckinViewEngine : WebFormViewEngine { public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache) { ViewEngineResult result; var routData = controllerContext.RequestContext.RouteData

Can I interleave two MVC view engines when searching for views?

一笑奈何 提交于 2019-12-11 04:11:45
问题 I'm using the WebForms and Razor view engines in my MVC project. They work just fine together. However, I have an inheritance-based project set up, such that I have multiple child projects derived from a base project. With just one view engine, this works such that MVC will search for a view in the child projects, and failing to find it, it will search the base. However, when adding the second view engine, this search pattern is broken, such that the WebForms engine searches the child and

ASP.NET MVC view engine performance

帅比萌擦擦* 提交于 2019-12-11 02:47:15
问题 I'm developing high load solution with final version of asp.net mvc. Recently our team noticed, that most of the time that takes a server to response to client is devoted to page rendering. Simple time-schedule looks like this: Page start - 1.8608363s Render module 1140/Modules/Owners start - 1.86859s Render module 1140/Modules/Owners Complete - 1.9081751s Render module 829/Modules/Links start - 1.9081788s Render module 829/Modules/Links Complete - 2.3380648s Render module 1036/Modules

Using Spark or Razor viewengine with OpenRasta

两盒软妹~` 提交于 2019-12-10 16:45:00
问题 has anyone used Spark or Razor view engine with OpenRasta framework? or any suggestion on the view engine other than the build in WebForms ? 回答1: There is Spark and Razor ViewEngine support for OpenRasta available at https://github.com/openrasta/openrasta-codecs-razor https://github.com/openrasta/openrasta-codecs-spark You will probably have to build from source from these locations. 来源: https://stackoverflow.com/questions/5863585/using-spark-or-razor-viewengine-with-openrasta

ASP.NET MVC Custom Attributes within Custom View Engine

故事扮演 提交于 2019-12-10 11:24:57
问题 Assuming I write a custom attribute... public class SpecialActionFilterAttribute : System.Web.Mvc.ActionFilterAttribute { public override void OnActionExecuted(ActionExecutedContext filterContext) { } public override void OnActionExecuting(ActionExecutingContext filterContext) { // set some parameters here. } public override void OnResultExecuted(ResultExecutedContext filterContext) { } public override void OnResultExecuting(ResultExecutingContext filterContext) { } } And then I create a

ASP.NET MVC View Engine Resolution Sequence

自闭症网瘾萝莉.ら 提交于 2019-12-09 10:05:05
问题 I created a simple ASP.NET MVC version 1.0 application. I have a ProductController which has one action Index. In the view, I created a corresponding Index.aspx under Product subfolder. Then I referenced the Spark dll and created Index.spark under the same Product view folder. The Application_Start looks like protected void Application_Start() { RegisterRoutes(RouteTable.Routes); ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new Spark.Web.Mvc.SparkViewFactory()); ViewEngines.Engines

Does Razor ViewEngine cache the rendered HTMLs?

时光怂恿深爱的人放手 提交于 2019-12-07 01:27:36
问题 I have a 2-level menu item: I have a list of department and each department has a list of stores. I have a Menu, PartialView which iterates through the Model (departments) and builds the menu: @model IEnumerable<Department> <ul> @foreach (var department in Model) { <li> <a href="#">@Model.DepartmentName</a> <ul> @foreach (var store in department.Stores) { <li><a href="some-url">@store.StoreName</a></li> } </ul> </li> } </ul> And this is how I call the Menu PartialView in my _layout.cshtml :

ASP.NET MVC Custom Attributes within Custom View Engine

拈花ヽ惹草 提交于 2019-12-06 08:56:49
Assuming I write a custom attribute... public class SpecialActionFilterAttribute : System.Web.Mvc.ActionFilterAttribute { public override void OnActionExecuted(ActionExecutedContext filterContext) { } public override void OnActionExecuting(ActionExecutingContext filterContext) { // set some parameters here. } public override void OnResultExecuted(ResultExecutedContext filterContext) { } public override void OnResultExecuting(ResultExecutingContext filterContext) { } } And then I create a custom ViewEngine, and override FindView/FindPartialView... public override ViewEngineResult FindView

Is there a way to make a @section optional with the asp.net mvc Razor ViewEngine?

依然范特西╮ 提交于 2019-12-05 22:21:34
问题 I have a Page.cshtml similar to the following (that does not work): @{ Layout = "../Shared/Layouts/_Layout.cshtml"; var mycollection = (ViewBag.TheCollection as IQueryable<MyCollectionType>); } <h2>@ViewBag.Title</h2> content here @if (mycollection != null && mycollection.Count() > 0) { @section ContentRight { <h2> Stuff </h2> <ul class="stuff"> @foreach (MyCollectionType item in mycollection ) { <li class="stuff-item">@item.Name</li> } </ul> } } As I said, this does not work. I want to not

installing the razor view engine for Visual Studio

蓝咒 提交于 2019-12-05 21:11:57
问题 I just downloaded and installed Web Matrix beta. I am really liking the razor view engine. Not so much the Web Matrix IDE. Is there any way to install razor view engine for use in the Visual Studio without installing WebMatrix? 回答1: Yes, as part of the ASP.NET MVC 3 Preview 1 released yesterday http://go.microsoft.com/fwlink/?LinkID=157073 回答2: What's currently offered in WebMatrix isn't really a ViewEngine in the current MVC sense, it's a parser/templating engine, more like T4 templates, in