在ASP.net MVC 2.0使用Url.Content [英] Using Url.Content in ASP.net MVC 2.0

查看:116
本文介绍了在ASP.net MVC 2.0使用Url.Content的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了很多的使用Url.Content引用JavaScript的形式MasterPages例子,在MVC 2。

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,

编译错误
  说明:该请求提供服务所需资源的编译过程中出现错误。请检查下列特定错误详细信息并适当地修改源$ C ​​$ C。

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.

编译器错误信息:CS0103:'URL'这个名字并不在当前的背景下存在

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

我还没有发现其中URL命名空间中声明,应使用额外的组件是什么?

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

VS2010,IIS 7,ASP.net MVC 2.0

VS2010, IIS 7, ASP.net MVC 2.0

推荐答案

请确保您的母版页继承System.Web.Mvc.ViewMasterPage

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

这篇关于在ASP.net MVC 2.0使用Url.Content的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆