razorengine

Razor engine cant find view

蓝咒 提交于 2019-12-19 18:28:07
问题 Im trying to render a html from a view without using a web request. I need the HTML as a string, internally, i do not wish to serve it. The viewEngine.FindView() returns a viewEnineResult that shows no view was found. It shows to search locations where it looked they look like this: /Views//PDFOperationsReportView.cshtml /Views/Shared/PDFOperationsReportView.cshtml (Observe the double forward slash in the first line) File structure (I placed it into a HTML snippet cause i couldnt manage to

ASP.NET MVC Razor view vs AngularJS

妖精的绣舞 提交于 2019-12-19 02:27:13
问题 I am using ASP.Net MVC with Razor syntax in Views. But with little research on performance enhancements I have found that View Engines takes a time to compile razor code to HTML. So is it good idea to use AngularJS in Views over razor syntax? If this improves performance then what are the other pros and cons of it? Thanks in advance. 回答1: Which route will give you better performance is dependent on several factors. zambeb's answer regarding mvc.net razor views is not accurate. mvc.net view s

RazorEngine: cannot use Html.Raw

微笑、不失礼 提交于 2019-12-17 19:57:19
问题 using RazorEngine outside asp.net I'm experiencing this error when I try to write raw html by using @Html.Raw("html string here") : Unable to compile template. The name 'Html' does not exist in the current context Can you help me? Thanks! 回答1: The solution has been found here: https://github.com/Antaris/RazorEngine/issues/34 It's enough to use @(new RawString("html string here")) or @Raw("html string here") instead of @Html.Raw("html string here") . I hope this helps! Bye 回答2: I implemented

How do I render a partial form element using AJAX

泄露秘密 提交于 2019-12-17 04:08:31
问题 I have a form that assembles sections of a larger form. For example: Html.RenderPartial("Partials/MealPreference", Model); I would like to dynamically add sections to the form. Given the nature of my partial views, I must pass the model along as well. In that, I am failing miserably. The markup on my containing page: <div id="additionalPreference"></div> <input type="button" value="Add Additional Preference" id="addPreference" /> <script> $(document).ready(function () { $('#addPreference')

How do I render a partial form element using AJAX

馋奶兔 提交于 2019-12-17 04:08:24
问题 I have a form that assembles sections of a larger form. For example: Html.RenderPartial("Partials/MealPreference", Model); I would like to dynamically add sections to the form. Given the nature of my partial views, I must pass the model along as well. In that, I am failing miserably. The markup on my containing page: <div id="additionalPreference"></div> <input type="button" value="Add Additional Preference" id="addPreference" /> <script> $(document).ready(function () { $('#addPreference')

How to fix StackOverFlowException in .NET

随声附和 提交于 2019-12-13 07:00:16
问题 ASP .NET 4.6 MVC controller creates Razor Template at runtime and runs it using RazorEngine. One big template causes Stack Overflow exception when running from Visual Studio or Method CompiledRazorTemplates.Dynamic.dbcfcaeeb:Execute () is too complex. when runing from Mono. If large number of divs are removed from template, it compiles and runs OK. How to fix this ? How to increase net stack size or any other idea ? Razor template which causes this has 2880 lines. It contains 228 variables

How to make a actionlink as Image in Asp.Net MVC4 Razpr View?

北慕城南 提交于 2019-12-13 04:03:32
问题 NET MVC4 with Entity Framework. I am trying Rating control , for that I am using @Url.Action . Now i have to convert action link to star image button. Please anyone give me an idea to getit. This is my code: <a href="@Url.Action("rated/4", "Rating")">Half</a> <a href="@Url.Action("rated/5", "Rating")">One</a> <a href="@Url.Action("rated/6", "Rating")">One and Half</a> <a href="@Url.Action("rated/7", "Rating")">Two</a> <a href="@Url.Action("rated/8", "Rating")">Two and half</a> 回答1: You can

RazorEngine “Unable to compile template” Error

独自空忆成欢 提交于 2019-12-13 03:59:51
问题 I'm using the following code to build and send an email using RazorEngine. //build email using template. string template = File.OpenText(EmailTemplatePath).ReadToEnd(); OrganizationInviteEmailTemplate model = new OrganizationInviteEmailTemplate() { FirstName = Invitation.FirstName, LastName = Invitation.LastName, Message = Message, OrganizationName = Invitation.Organization.OrganizationName, ConfirmUrl = string.Format(ConfirmUrlTemplate, Invitation.InviteCode) }; string body = Razor.Parse

RazorEngine on Mono - TemplateCompilationException thrown

狂风中的少年 提交于 2019-12-13 03:00:25
问题 I have Mono 3.3.0 running on my Linux box. I am trying to use RazorEngine 3.3.0 (from NuGet). Unfortunately it now throws this exception System.Exception: Unable to compile template. The predefined type System.Collections.Generic.IReadOnlyList' is defined multiple times. Using definition from mscorlib.dll' However the code works just fine on my Windows machine. Am I missing something obvious, or does this simply not work on Mono? [Edit] I just found this information in the "Errors" property

creating dynamic id for divs in MVC with Razor… with a twist

时光怂恿深爱的人放手 提交于 2019-12-13 02:36:13
问题 The twist being, all answers that I found on the topic simply do not seem to work. I tried just about all formattings I found in answers to this question and made a few desperate attempts on my own, but none of them have any effect. It's almost as if razor wasn't there, but other razor synthax in the same cshtml file executes without trouble. As most of the time, the div is declared in a loop and its name should be appended by i. Here's some things I tried, not in the order I tried them in.