asp.net-mvc - 在 ASP.net MVC 2.0 中使用 Url.Content

标签 asp.net-mvc

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

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

但是在运行时我失败了,

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”。

我还没有找到在哪里声明 Url 命名空间,是否应该使用其他程序集?

VS2010、IIS 7、ASP.net MVC 2.0

最佳答案

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

关于asp.net-mvc - 在 ASP.net MVC 2.0 中使用 Url.Content,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3912508/

相关文章:

asp.net - 如何全局创建 CustomPrincipal(有和没有 AuthorizeAttribute)

c# - 为什么 EF 说我的模型已更改,而实际上它没有更改?

c# - MVC 中不支持关键字 : '"data source'.

asp.net-mvc - 在 asp.net mvc 中查找我的 View

asp.net - .net core 3.1 通过 URL 进行本地化/文化 - localhost/en/area?/controller/action

jquery - 将 jquery 验证添加到 ASP.NET MVC 页面中帖子的选择下拉列表

c# - 返回上一 View 并显示 ModelState.IsValid 为 false 的错误

c# - 使用 Bootstrap 从 HTML 转换为 .NET MVC

c# - 如何在C#中搜索类中的字符串

asp.net - 在 Dapper 中处理 Oracle 数据库连接