razorengine

Razor Engine Library throws error on azure function

£可爱£侵袭症+ 提交于 2019-12-13 02:12:47
问题 I am using RazorEngine Library and it throws error in azure function app when I call compile function service.Compile(name: "TemplateMaster", modelType: modelType); Exception Message: The given path's format is not supported. at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath) at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath) at System.Security.Permissions.FileIOPermission.AddPathList

how to remove the querystring parameters in url in mvc4 with razer using url.action

我的梦境 提交于 2019-12-13 01:43:34
问题 url.action is : <li><a href="@Url.Action("CategoryLevel", "Product", new { CategoryId = @item._categoryId, ProductName = @Html.Raw(item._categoryName) })">@Html.Raw(item._categoryName)</a></li> it works fine but i dont want to display the qyery string in url url is: http://localhost:99/Product/CategoryLevel?CategoryId=16&ProductName=Common%20Conditions i want to display this as `http://localhost:99/Product/CategoryLevel/16/Common%20Conditions` (or)`http://localhost:99/Product/CategoryLevel

Cannot use MvcHtmlString/IHtmlString with RazorEngine

走远了吗. 提交于 2019-12-12 13:16:45
问题 I just started playing around with the RazorEngine and I'm stumbling when using a static helper method. It just produces an MvcHtmlString/IHtmlString for the template. When calling Razor.Parse(...) I get RazorEngine.Templating.TemplateCompilationException : Unable to compile template. Der Typ 'System.Web.IHtmlString' ist in einer nicht referenzierten Assembly definiert. (not referenced) Fügen Sie einen Verweis auf die Assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken

How to make intellisense works with RazorEngine?

…衆ロ難τιáo~ 提交于 2019-12-12 07:43:54
问题 I am trying to configure RazorEngine so that intellisense works on views. I add RazorEngine and Microsoft.AspNet.Mvc using nuget. I create TestView.cshtml and declare @model MyModel but it says The name 'model' does not exist in the current context . I also cannot use intellisense inside the view. Do I miss any step here? How to enable intellisense in the View? 回答1: You can use @using RazorEngine.Templating @using Namespace.Of.My.Model @inherits TemplateBase<MyModel> on the top of your

Cannot find view located in referenced project

独自空忆成欢 提交于 2019-12-11 10:32:40
问题 My solution consist of 2 projects: MyApp.Rest MyApp.Core Core uses Razor templating to generate emails and reports. Rest is a WebAPI only and references Core. Rest has the startup file, where Razor configuration takes place. Core will also be used by other projects in the future. The problem is I am not able to make the view engine to locate view files even though I have added the output directory as a FileProvider for razor and the template has been copied to the output directory. Output

Is there a way to terminate MVC Razor @: line?

落花浮王杯 提交于 2019-12-11 02:34:04
问题 Consider this example: <input type="checkbox" @if (flag) { @: checked } /> The problem is that the } /> is conceived by the Razor engine as part of the output string. I've tried to use parenthesis but no luck. Is there a way to terminate the @: operator in same line, or I'll have to split it to other line / use ternary operator? Update A very common use-case of my request can be adding a class if a value is true: <div class='container @(active ? "active")'/> So if the : of the ternary

Wrong port number in mvc 4 windows Azure Request.Url

余生长醉 提交于 2019-12-10 19:24:11
问题 I am writing a small asp.net MVC4 web application. The project template is azure mvc 4 template in visual studio 2012. When I request for Request.Url in razor view I get the wrong port number. For example if my webpage url is http://127.0.0.1:81/mypage I get http://127.0.0.1:82/mypage when I get the url from Request.Url. I am running it in the default azure emulator I get with visual studio 2012. Why the port number is wrong? How to correct it? 回答1: Found the answer. This blog article

Using-Statement in RazorEngine (without the HtmlHelper from MVC)

自作多情 提交于 2019-12-09 17:25:24
问题 I'm using the RazorEngine without the MVC-Framework. That means I don't have the HtmlHelper for creating templates. That's fine, I don't need any methods from it anyway. But I need to create my own methods like the BeginForm. Now those are done with HtmlHelper.ViewContext.Writer.Write, which I don't have. Is there a "out of the box"-way to do that, or do I have to do some magic here? 回答1: The RazorEngine is designed with deriving your own types for use in the Engine itself. First create your

Pass Table Value from View to Controller MVC

守給你的承諾、 提交于 2019-12-08 03:58:26
问题 Can I pass table td values to controller? View strongly typed: @using (Html.BeginForm("PostClick", "Vendor", FormMethod.Post)) { <table class="tblData"> <tr> <th> @Html.DisplayNameFor(model => model.First().SubmittedDate) </th> <th> @Html.DisplayNameFor(model => model.First().StartDate) </th> </tr> <tr> <td> @Html.DisplayFor(modelItem => item.SubmittedDate) </td> <td> @Html.DisplayFor(modelItem => item.StartDate) </td> </tr> </table> <input type="submit" value="submit" /> } Contoller code:

Public Conditional Razor Views with minified JS and CSS

折月煮酒 提交于 2019-12-07 11:32:10
问题 I am using ASP.NET MVC 5 to develop my website. I'm using Grunt to minify my CSS and JS. Everything works fine, but I need to change the route source of my files if I'm making a publish (release mode) or I'm debugging (I need to read my CSS and JS clearly). Something like this: [Debug Mode] <script src="scripts/myscript.js"></script> [Relase Mode or Public Mode] <script src="dist/myscript.min.js"></script> I have read this post on StackOverflow(Razor view engine, how to enter preprocessor(#if