Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Url.Content in ASP.net MVC 2.0

Tags:

asp.net-mvc

I've seen a lot of examples using Url.Content to reference javascript, form MasterPages in MVC 2.

    <script src="<%: Url.Content("~/Scripts/jquery-1.4.1.min.js") %>" type="text/javascript"></script>

But on runtime I've got failure,

Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0103: The name 'Url' does not exist in the current context.

I haven't find where Url namespace is declared, should additional assemblies be using?

VS2010, IIS 7, ASP.net MVC 2.0

like image 967
Alexander Beletsky Avatar asked Oct 12 '10 07:10

Alexander Beletsky


1 Answers

Make sure your master page inherits System.Web.Mvc.ViewMasterPage

like image 173
Erik Avatar answered Oct 05 '22 13:10

Erik