我想在我的asp.net核心应用程序的某些页面上呈现空布局。为此,我在中使用了此代码_ViewStart.cshtml。
@{
var controller = HttpContext.Current.Request.RequestContext.RouteData.Values["Controller"].ToString();
string cLayout = "";
if (controller == "Empty")
{
cLayout = "~/Views/Shared/_Empty_Layout.cshtml";
}
else
{
cLayout = "~/Views/Shared/_Layout.cshtml";
}
Layout = cLayout;
}
这段代码适用于,Asp.NET MVC App但给出的错误.NET Core App。错误是The name 'HttpContext' does not exist in the current context
相关分类