Asp.net mvc 3 如何从添加到特定视图的_LyoutView中排除某些内容
我的LyoutView上有这样的脚本:Asp.net mvc 3 如何从添加到特定视图的_LyoutView中排除某些内容,asp.net-mvc-3,Asp.net Mvc 3,我的LyoutView上有这样的脚本: <noscript> <meta http-equiv="refresh" content="0; URL=/Noscript"> </noscript> @if (ViewContext.Controller.ValueProvider.GetValue("action").RawValue != "Noscript") { <noscript> <meta http-eq
<noscript>
<meta http-equiv="refresh" content="0; URL=/Noscript">
</noscript>
@if (ViewContext.Controller.ValueProvider.GetValue("action").RawValue != "Noscript")
{
<noscript>
<meta http-equiv="refresh" content="0; URL=/Noscript">
</noscript>
}
但当禁用javascript的用户重定向到该页面时,该页面的无限请求将发生,因为该页面也包含上述代码
所以我想ASP.NETMVC中可能有一些现成的东西可以帮上忙
基本上,我希望将来自_LyoutView的代码添加到除Noscript视图之外的所有视图中
我可以在LyoutView上这样做:
<noscript>
<meta http-equiv="refresh" content="0; URL=/Noscript">
</noscript>
@if (ViewContext.Controller.ValueProvider.GetValue("action").RawValue != "Noscript")
{
<noscript>
<meta http-equiv="refresh" content="0; URL=/Noscript">
</noscript>
}
@if(ViewContext.Controller.ValueProvider.GetValue(“操作”).RawValue!=“Noscript”)
{
}
但是可能还有更好的方法吗?您可以检查
请求
对象的RawUrl
属性,看看它是否包含术语“Noscript”,我假设它不会是URL的一部分,除非我们在该页面上
@if(!Request.RawUrl.Contains("Noscript"))
{
<noscript>
<meta http-equiv="refresh" content="0; URL=/Noscript">
</noscript>
}
@if(!Request.RawUrl.Contains(“Noscript”))
{
}
您可以检查请求
对象的RawUrl
属性,查看它是否包含术语“Noscript”,我假设它不会是URL的一部分,除非我们在该页面上
@if(!Request.RawUrl.Contains("Noscript"))
{
<noscript>
<meta http-equiv="refresh" content="0; URL=/Noscript">
</noscript>
}
@if(!Request.RawUrl.Contains(“Noscript”))
{
}