如何将查看器重定向到URL?
我注意到有人问How can I make a redirect page using jQuery?,但我不知道这应该去哪里。
我在控制器试过:
window.location.replace(“http://192.168.1.109/MWT/Taglist/ShowMap”LastId);
并认为:
<% if (BreakCount >= 8) { var url = "http://192.168.1.109/MWT/Taglist/ShowMap" + LastId; window.location.replace(url); } %>
这两个都没有工作。在这两个地方,窗口下面有一个红色的波浪线,当我将鼠标悬停在它上面时,消息说“名称”窗口在当前上下文中不存在。
任何帮助将不胜感激!
= D
解决方法
你的问题是标记为MVC 3,所以我会给你的答案,尽管你列出的JavaScript示例。在你的控制器类中使用这段代码:
public ActionResult MyAction() { // Use this for an action return RedirectToAction("ActionName"); // Use this for a URL return Redirect("http://192.168.1.109/MWT/Taglist/ShowMap" + LastId); }
这发生在服务器上,这意味着客户端浏览器接收到一个重定向响应,浏览器可能会提交一个附加请求。如果你返回一个带有JavaScript的页面,它将必须加载一个页面,运行JavaScript(假设它是在客户端的浏览器上启用),加载下一页。在其他问题中,使用JavaScript意味着,如果用户按下返回按钮,他们将被重复重定向回到他们当前所在的页面。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。