viewengine

Does Razor ViewEngine cache the rendered HTMLs?

a 夏天 提交于 2019-12-05 04:58:48
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 : @Html.Partial("Shared/_Menu", MyApplicationCache.departments) As you can see I am passing the same model

ASP.NET how to resolve CS1513: } expected error on page

匆匆过客 提交于 2019-12-05 01:45:04
I am getting an error at run time when viewing my ASP.NET page in the browser. I am not getting any build errors however I am getting the following compiler error at runtime: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1513: } expected Source Error: Line 329: #line hidden Line 330: __output.Write("\r\n\t\t\t</div>\r\n\t\t"); Line 331: } Line 332: Line 333: private System.Web.UI.Control __BuildControl_

ASP.NET (MVC) - render page to a file

随声附和 提交于 2019-12-04 16:06:38
I have to create a bunch of static html files as console / winform job. The current solution uses a string builder. Having used ASP.NET-MVC with strongly typed view pages (System.Web.Mvc.ViewPage) I was wondering if it is possible to leverage these view pages and have them output to a stream or file without building an ASP.NET solution. Essentially I'd like to create the viewpage, pass in the strongly typed object, and render the result. I'm also open to other view engines. If this ends up requiring bringing over the whole kitchen sink, then I can just do a string builder style. Thanks. What

Extending WebFormView in MVC

限于喜欢 提交于 2019-12-04 06:32:35
问题 I want to extend the WebFormViewEngine so that I can perform some post-processing - I want it to do it's stuff, then hand me the Html back, so I can do put some final touches to it. It needs to be done as a View/ViewEngine because I need access to the ViewData. Unfortunately there seems to be no way to get the Html back from the WebFormView, and no way to hand a custom HtmlTextWriter to the WebFormView or ViewPage. Surely there's a way to do this? No? Littlecharva 回答1: You can use Action

Output Cache problem on ViewEngine that use 2 separate view for 1 controller

喜欢而已 提交于 2019-12-04 05:42:24
问题 http://www.hanselman.com/blog/MixMobileWebSitesWithASPNETMVCAndTheMobileBrowserDefinitionFile.aspx To the sake of simplicity, please try out this. Basically, I am trying to do the mobile view engine, but then i found out that I have outputcache, which will cache one of 2 view (PC view) and then when i tried to access through mobile, it automatic show PC view. So is there anyway to avoid this problem while still keeping the outputcache? Thanks 回答1: Is your problem that out of the box variance

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

一曲冷凌霜 提交于 2019-12-04 04:59:09
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 define the section if there's nothing in the collection. Is there any way to have something like this

Razor vs Webforms view engine for new ASP.NET MVC 3 site

倾然丶 夕夏残阳落幕 提交于 2019-12-04 02:00:27
Razor is prettier (and is new therefore cool). Webforms is something I am already familiar with. Naturally I would unquestionably go for the new thing to learn - Razor. But I have heard of two disadvantages that worry me: can't easily reuse existing web forms controls - in the rare instance I may need to drag something across... I'll reiterate - 'RARE' I hear it is less efficient at rendering (takes longer than web forms) So what are the advantages of Razor over Webforms view engines when using ASP.NET MVC 3? marcind This has already been addressed by the following question: Does Razor syntax

Custom ViewEngine ASP.NET MVC 3

时间秒杀一切 提交于 2019-12-03 20:26:22
I am looking for the simplest solution for the custom viewengine for asp.net mvc. So I can over-ride the path to look for the views. Actually, I am trying to build a theme system in my solution. I looked over web but found solution which is hard to learn and implement. Thanks This is what I use. It looks for views in a theme folder. Set the theme name, in the first line of the constructor. It also supports mobile views, but you'll need something like 51 Degrees Mobi to provide you with the mobile browser details. using System; using System.Collections.Generic; using System.Web; using System

ASP.NET MVC View Engine Resolution Sequence

…衆ロ難τιáo~ 提交于 2019-12-03 12:17:38
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.Add(new WebFormViewEngine()); } My expectation is that since the Spark engine registers before default

Razor Generator: how to use view compiled in a library as the partial view for master defined in main mvc project

倖福魔咒の 提交于 2019-12-03 12:12:22
We have an ASP.NET MVC 4 application with around 3000 views in it. We've decided to split this set of views into separated DLLs and compile it with RazorGenerator. We keep only main _Layout.cshtml and related files in the main MVC project. We cannot load partial views from DLL together with master view in main MVC project. Detailed description is below. What is already done: The views compile successfully into DLLs (I've confirmed that they are in the binary) The PrecompiledMvcEngine object is created and registered for each DLL containing views using the code below in Application_Start in