温馨提示×

response.redirect的用法有哪些

小亿
750
2023-07-08 21:36:41
栏目: 编程语言
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

response.redirect的用法有以下几种:

  1. 重定向到另一个URL:

response.redirect(“http://www.example.com”);

  1. 重定向到相对路径:

response.redirect(“/example”);

  1. 重定向到另一个页面:

response.redirect(“example.html”);

  1. 重定向并传递参数:

response.redirect(“example.html?param1=value1&param2=value2”);

  1. 重定向到另一个页面并设置状态码:

response.redirect(“example.html”, 301);

  1. 重定向到另一个页面并设置状态码和响应头:

response.redirect(“example.html”, 301, {“Location”: “http://www.example.com”});

注意:response.redirect只能在服务器端使用,用于向客户端发送重定向响应。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:如何高效的使用Response.Redirect

0