我的_LyoutView上有这样的脚本:
<noscript>
<meta http-equiv="refresh" content="0; URL=/Noscript">
</noscript>但是当禁用了javascript的用户重定向到该页面时,该页面的无限请求就会发生,因为该页面也包含上述代码。
所以我只是在想,在ASP.NET MVC中可能有一些开箱即用的东西可以提供帮助?
基本上,我希望来自_LyoutView的代码被添加到除Noscript视图之外的所有视图中。
我可以在_LyoutView上这样做:
@if (ViewContext.Controller.ValueProvider.GetValue("action").RawValue != "Noscript")
{
<noscript>
<meta http-equiv="refresh" content="0; URL=/Noscript">
</noscript>
}但是有没有更好的方法呢?
发布于 2011-08-20 00:38:31
您可以检查Request对象的RawUrl属性,看看它是否包含术语"Noscript“,我假设它不会是网址的一部分,除非我们在该页面上。
@if(!Request.RawUrl.Contains("Noscript"))
{
<noscript>
<meta http-equiv="refresh" content="0; URL=/Noscript">
</noscript>
}https://stackoverflow.com/questions/7124654
复制相似问题