Search code examples
c#asp.net-mvc-4razorrazorenginerazorgenerator

Unable to modify cshtml page in mvc


There is a mvc application, in which I am trying to modify in pre-compiled CSHTML page(Index.cshtml)

@using System.Web.Mvc.Html
@model Services.Admin.ViewModels.IndexViewModel
@{
Layout = "~/Views/Admin/_Layout.cshtml";
ViewBag.Title = Resources.AdminResources.Index_Title;
}
<div class="container">
<div class="masonry">
    <div class="item col-lg-4 col-md-4 col-sm-4">
        <h3>Event Clinics</h3>
        <table class="table table-striped table-bordered table-hover">
            <tbody>
            <tr>
                <td class="max-width">
                    @Html.ActionLink("Premier Instructors", "Index", "PremierInstructor")
                </td>
                <td></td>
            </tr>
            <tr>
                <td class="max-width">
                    @Html.ActionLink("Reports", "Index", "Reports")
                </td>
                <td></td>
            </tr>
            <tr>
                <td class="max-width">
                    @Html.ActionLink("Users", "Index", "Users")
                </td>
                <td></td>
            </tr>
            </tbody>
        </table>
    </div>   
</div>

Here is also respective Index.generated.cs, in which all code is written with help of "WriteLiteral".

When I am trying to add/modify in .cshtml form, it's impact not showing on UI.

I have also find out on various sites and found that these cshtml is already compiled using "RazorGenerator" tools.

Now My problem is this, when I am going to make any changes in this type of cshtml file, it is not reflected on screen.


Solution

  • In case of RazorGenerator based pre-compiled .cshtml forms as there is need to modify it's html then follow below steps.

    1. Right Click on .chstml file (ex. index.cshtml).
    2. Click on "Properties".
    3. Under "Advanced" section remove "RazorGenerator" from "Custom Tool" option.
    4. DO CHANGES IN CSHTML FILE.
    5. Again follow above 1,2 steps.
    6. Under "Advanced" section add "RazorGenerator" in "Custom Tool" option.
    7. Save form and run it.

    Now you will be seeing all the changes in UI.