由于我使用具有安装NuGet包的Microsoft.AspNet.Razor Web应用程序。
在Web窗体页( 的.aspx),我可以使用RESOLVEURL(),但在剃刀页(.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>