FAQ Database Discussion Community


How to use Url.Action in Razor view in App_Code folder

asp.net-mvc,asp.net-mvc-4,razor,html-helper,razor-2
How to use Url.Action() in Razor helper from App_Code folder ? I tried according to Why I cant use Html.RenderPartial in razor helper view File in App_Code Folder? @using System.Web.Mvc.Html @helper Tabel(System.Web.Mvc.HtmlHelper html) { @Html.Raw(Url.Action("Index", "Home")) } but got compile error CS0103: The name 'Url' does not exist in the...

MVC 5 routing issue with new url for subcategories

asp.net-mvc-5,asp.net-mvc-routing,razor-2,asp.net-mvc-viewmodel
In my productcontroller I have two actionresult returning methods: [Route("Shop/{brand}/{category}/{subcategory?}/{page:int?}")] public ActionResult Index(string brand, string category, string subcategory, int? page, SortOptions currentSort = SortOptions.SinceDesc) { //... and [HttpPost] [Route("Shop/{brand}/{category}/{subcategory?}/{page:int?}")] public ActionResult Index(ProductsViewModel pvm) { //... And this is my razor view: @using (@Html.BeginForm("Index", "Products", FormMethod.Post)) { @Html.DropDownListFor(x => x.SubCatID,...

Add/remove html markups according to the content of RenderBody()

c#,asp.net,asp.net-mvc,asp.net-mvc-5,razor-2
In my _Layout.cshtml: <section class="container content-section text-center"> @RenderBody() </section> I only want to have the "section" around when the "body" is not the home page. I was thinking of detecting url, but soon realized that I will have many Urls bound to the website, it's not the smart way to...

Razor runcompile is not allowing me to debug

c#,razor,razor-2,razorengine
I'm using the latest version of razor from. https://github.com/Antaris/RazorEngine I want to attached it to some cshtml and debug against it. The readme states the following Debugging One thing you might want to enable is the debugging feature: config.Debug = true; When Debug is true you can straight up debug...

Wrap each newline (/n) with
  • razor,razor-2
    I have a small project which i have a question for. Users fill out a form and after submitting it i wish to wrap each new line in the textarea with <li></li>. So basically i have the following code. <textarea name="Questions"></textarea> On the other submit.cshtml i wish to wrap each...