没有脚本标签的问题
我在我的母版页上没有放置任何脚本标记,如果用户没有启用 javascript 或者其浏览器不支持 javascript,它会重定向到特定视图。我正在使用这段代码
<noscript>
<% Response.Redirect("../UserLogin/Error"); %>
</noscript>
,但问题是每次我打开页面时它都会重定向我,尽管我的 javascript 已启用。我使用 asp.net mvc2 可能有什么问题或者有其他方法可以做到这一点吗?
Im placing no script tag on my master page that if a user dont have javascript enabled or its browsers doesnt support javascript it redirect to a specific view. im using this code
<noscript>
<% Response.Redirect("../UserLogin/Error"); %>
</noscript>
but the problem is its redirecting me everytime i open the page although my javascript is enabled. Im using asp.net mvc2 what may be the problem or is there is any other way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
标签
noscript
在客户端(浏览器)中进行评估。服务器不知道客户端是否有脚本支持,所以每次都会重定向。编辑
更好地解释一下:服务器只是创建一个字符串(HTML)并将其发送到浏览器。它不会解析浏览器是否支持脚本。
编辑2
您可以使用元刷新标签。请参阅:
我在 Firefox 中测试并有效。
The tag
noscript
is evaluated in the client (browser). The server doesn't know if client has script support, so every time it redirects.EDIT
Explain better: the server just creates a string (HTML) and send it to browser. It doesn't parse to see if browser has script support.
EDIT 2
You can use meta refresh tag. See:
I tested in firefox and works.
Response.Redirect
在服务器端执行,它会向浏览器发送 302 状态码,浏览器会自动重定向。您可能想要:Response.Redirect
is executed on the server side and it will send a 302 status code to the browser which will automatically redirect. You probably want: