我已经看到了很多使用 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/