c# - 执行 HTTP 307 重定向
问题描述
出于技术原因,我们需要执行 HTTP 307 重定向而不是 302。
对于 302,我会这样做:
HttpContext.Current.Response.Redirect(url)
对于 301,我这样做:
HttpContext.Current.Response.RedirectPermanent(url)
我将如何实施 307?
解决方案
通过添加位置标头并手动执行重定向来解决此问题:
HttpContext.Current.Response.StatusCode = 307;
HttpContext.Current.Response.StatusDescription = "Temporary Redirect";
HttpContext.Current.Response.AddHeader("Location", redirectURL);
HttpContext.Current.Response.End();
推荐阅读
- eclipse - 如何在 Eclipse 中包含过滤文件夹中的单个资源
- c# - 在对象向量中引用对象
- html - 我正在尝试在 JSP 中将一个月添加到当前月份并在 html 教科书中显示结果
- python - 运行 python 脚本时的 Crontab 日志数据
- deep-learning - 使用 TikZ 制作堆叠的 3D 块
- synchronization - Keycloak 将注册用户同步到本地数据库
- python-3.x - python中用于测量扫描心电图(ECG)间隔的简单图像处理解决方案
- android - Xamarin.Forms.Platform.Android.Platform+DefaultRenderer 来自本机句柄
- javascript - JavaScript - 找到最高 div 的高度
- python - 将文本文件中的文件读入列表列表