Resources to learn MVC 3


Step by Step tutorials and PluralSight Videos covering MVC 3

Read More


Comments (1)

  1. I am having a requirement where i want to load my .cshtml file from the database. My .cshtml file comes from the database as filestream which I am able to parse as normal string which looks as below:

    <h2>SecondPage You are from .cshtml Page</h2>

    @{Html.RenderAction("Left", "Left");}

    I need to show this web page for which i am trying to parse the .cshtml file as

    // my SP which will return byte array from database

    byte[] objContext = byte[])objdbmcptestEntities.GetFile(1).SingleOrDefault().FileData;

    var template = System.Text.Encoding.ASCII.GetString(objContext);

    //var template = "@{ @:The day is: @DateTime.Now.DayOfWeek. It is a <b>great</b> day!}";

    //This code works fine

    //The code below does`t work

    var template = "Hello @Model.Name! Welcome to Razor!<h2>SecondPage You are from code behind</h2><div>@Model.Name</div><div>@{Html.RenderAction("Left", "Left");}</div>";

    return Razor.Parse(template, new { Name = "World" });

    Please give me some solution ASAP.

Skip to main content