razorgenerator

User strings used by the program exceeds allowed limit by visual studio 2019

安稳与你 提交于 2021-01-29 07:50:17
问题 I have been working with RazorGenerator.Mvc and RazorGenerator.MSBuild to precompile the views. The error i face when i try to build the project. CS8103 C# Combined length of user strings used by the program exceeds allowed limit. Try to decrease use of string literals. Visual Studio 2019 Version 16.3 When i remove RazorGenerator packages, clean and rebuild, the error is gone. This github issue indicated that the fix will be in VS 2019. I tried everything to debug the issue but could not

CompilationFailedException when using IRazorViewEngine in non Sdk.Web projects to render Razor pages

烈酒焚心 提交于 2020-02-05 14:56:12
问题 I am trying to use IRazorViewEngine in a console application <Project Sdk="Microsoft.NET.Sdk"> (not <Project Sdk="Microsoft.NET.Sdk.Web"> ) to render a .cshtml page in memory. I registered every needed dependency in the ServiceProvider . While calling the following line I get a CompilationFailedException : _viewEngine.GetView(directory, name, true); Exception: Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException: One or more compilation failures occurred: kmcajniq.bah(4,20):

RazorGenerator can't see custom cshtml helper

跟風遠走 提交于 2020-01-12 06:37:08
问题 I'm having a problem with RazorGenerator: it can't compile views that uses my custom helper: App_Code/ViewHelper.cshtml @helper test(System.Web.Mvc.HtmlHelper html) { <h4>Test</h4> } Views/Test.cshtml (...) @ViewHelper.test(this.Html) (...) When I try to compile my project I get this error for Test.cshtml: The name 'ViewHelpers' does not exist in the current context I tried adding various namespaces to my Views/web.config file: <system.web.webPages.razor> <host factoryType="System.Web.Mvc

RazorGenerator can't see custom cshtml helper

爱⌒轻易说出口 提交于 2020-01-12 06:37:07
问题 I'm having a problem with RazorGenerator: it can't compile views that uses my custom helper: App_Code/ViewHelper.cshtml @helper test(System.Web.Mvc.HtmlHelper html) { <h4>Test</h4> } Views/Test.cshtml (...) @ViewHelper.test(this.Html) (...) When I try to compile my project I get this error for Test.cshtml: The name 'ViewHelpers' does not exist in the current context I tried adding various namespaces to my Views/web.config file: <system.web.webPages.razor> <host factoryType="System.Web.Mvc

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

≡放荡痞女 提交于 2020-01-01 04:37:27
问题 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

Print and/or modify the c# version that the razor compiler service uses to compile cshtml

十年热恋 提交于 2019-12-23 07:00:58
问题 I'd like to be able to find out which C# version razor uses to compile my cshtml templates. The reason why I want this, is this breaking change. We had a lambda in a foreach statement that worked fine on our local dev machines but produced a bug on our test environment (which doesn't have C# 5 installed). This bug was VERY hard to debug (we even copied all the test environment DLLs and databases and were still not able to reproduce the bug). So to prevent this dev/test difference in the

MVC4 hosting views from other MVC project

杀马特。学长 韩版系。学妹 提交于 2019-12-22 08:21:04
问题 I am attempting to figure out how to host MVC4 apps that were built under different solutions. There are many examples of doing this on SO and on the web using the RazorGenerator nuget package with Areas - it works very well. In my situation, I want to avoid using areas - every application my company develops will be in it's own MVC4 project (then collectively in the same solution). I've integrated RazorGenerator into my apps, the code gen is working as expected. However, my host solution can

CheckBoxList for Enum types MVC Razor

亡梦爱人 提交于 2019-12-21 20:06:25
问题 In my c#.net MVC application i would like to display checkbox list for Enum types. I have an enum type [Flags] public enum ModeType { Undefined = 0, Read= 1, Edit= 2 } and my Model is Public TrainingModel { public int UserID {get;set;} public ModeType Type {get;set} } In my view i need two checkbox one for Read and the other for Edit So i tried @Html.CheckBoxFor(m => m.Type== ModeType.Read) @Html.CheckBoxFor(m => m.Type== ModeType.Edit) But this give me error "Templates can be used only with

Is there an example on using Razor to generate a static HTML page?

喜夏-厌秋 提交于 2019-12-19 10:03:49
问题 I want to generate a static HTML page by RAZOR, basically by using includes of partial sub pages. I have tried T4 as well and do look for an alternative: see here and here This answer says it is possible - but no concrete example I have installed Razor generator because I thought this is the way to go, but I do not get how to generate static HTML with this. Best would be a complete extension which behaves like the T4 concept, but allows me to use the RAZOR syntax and HTML formatting (the

Using PrecompiledMvcEngine FindView throws InvalidOperationException and looks for View cshtml files

风流意气都作罢 提交于 2019-12-12 03:33:44
问题 I got an InvalidOperationException when the MVC controller tried to FindView while using the PrecompiledMvcEngine . Using on a machine that has VS2012, MVC4 and deployed to IIS 回答1: After looking at the source code of ControllerBase.FindView to ViewEngineCollection.FindView to VirtualPathProviderViewEngine to PrecompiledMvcEngine, found that _mappings in PrecompiledMvcEngine had a count of 0. (Tx to Reflection and Open source.) The reason is that there was not Type assignable to