【发布时间】:2014-06-13 14:21:40
【问题描述】:
因为我使用的是安装了 NuGet 包的 Microsoft.AspNet.Razor 的 Web 应用程序。
在 WebForm 页面 (.aspx) 中,我可以使用 ResolveUrl() 但在 Razor 页面 (.cshtml) 中,我收到此错误 -->
"x:\Source\Foo.Dealer\Foo.Dealer.WebApp.Mobile\Member\DmsDashboard.cshtml(103): error CS0103: The name 'Url' does not exist in the current context"
源代码在这里..
@section HeadJavascriptLibraryFile
{
<script type="text/javascript" src="@Url.Content("~/scripts/webpages/setting-dmsdashboard.js")"></script>
}
和
<img src="@(Url.Content("~/images/miscellaneous/reportandpiechart2.png"))" alt="" />
根据要求提供源代码...
//LayoutMembmerGeneral.cshtml
@using Foo.Dealer.WebApp.Mobile.Infrastructure;
@{
if (LoginManagementTools.DealerUserLoginValidation_BrowsingPage(HttpContext.Current.Request, HttpContext.Current.Response, HttpContext.Current.Session) == false) { }
}<!DOCTYPE html>
<html>
<head>
<title>@Page.Title</title>
@RenderSection("HeadJavascriptLibraryFile", false)
</head>
<body>
@RenderBody()
</body>
</html>
//DmsDashboard.cshtml...
@using Foo.Dealer.WebApp.Mobile.Infrastructure
@using System.Web.Mvc;
@{
Page.Title = "A New Dawn In Auto Pricing";
Layout = "LayoutMemberGeneral.cshtml";
}
@section HeadJavascriptLibraryFile
{
}
<div id="WebLayout1">
<img src="@Url.Content("images/miscellaneous/reportandpiechart2.png")" alt="" />
</div>
【问题讨论】:
-
另外你运行的是什么版本的 Visual Studio?
-
当您添加
@using System.Web.Mvc时,智能感知是否启动? (顺便说一下,没有分号) -
是的,它确实开始了。