I am working on Asp.Net MVC 4 web application. This is first time I am using RazorJS in my application. I have installed it from NuGet Package Manager. After installing, new two references are added in my project ie. RazorEngine(Version 2.1.4113.149) and RazorJS(Version 0.4.3.0). Now as per instructions given in RazorJS official website here. I have added following code in my view(.cshtml) file.

@Html.RazorJSInclude("~/Scripts/JavaScriptFile.js")

and following code in my external javascript file(JavaScriptFile.js)

var s = "hello at @DateTime.Now";
alert(s);

Now when I run application and access my view page. Instead of showing javascript alert with text(with current datetime), it do nothing. In HTML it shows generated scripts tag like this

<script src="/razorjs.axd?fn=/Scripts/JavaScriptFile.js" type="text/javascript"></script>

When I try to access this url(http://localhost:1234/razorjs.axd?fn=/Scripts/JavaScriptFile.js), it shows following error

Could not load type 'System.Web.Razor.Parser.MarkupParser' from assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

As per this I think there is issue in System.Web.Razor version 2.0.0.0(In MVC 4 it's version 2). So to cross check it I created MVC3 web application in which System.Web.Razor version is 1.0.0.0 and in MVC3 application it works properly. So my question is How do I make it workable in my Asp.Net MVC4 application which using System.Web.Razor version 2.0.0.0

Thanks in advance....

Related posts

Recent Viewed