标签: http-status-code-302

执行操作并重定向到相同的 URL 不会刷新页面

我们正在使用 Apache、Python 和 Django 开发一个新网站。

在开发阶段,没问题,但是一旦绑定到Apache,使用Firefox 3.5.3,我们遇到了一个奇怪的问题。

我们坚持:

http://website.fr/search/

当我们想改变研究的顺序时,我们将用户发送到:

http://website.fr/search/order/price/

此页面更改会话变量并使用代码 302 重定向到:

http://website.fr/search/

问题是 Apache 发送了 302 Apache 代码,而 Firefox 不刷新页面。当我们将用户重定向到他之前所在的页面时,我们遇到了同样的问题。

我们应该怎么做才能强制刷新页面?

python django http httpwebrequest http-status-code-302

3
推荐指数
1
解决办法
1693
查看次数

如何使用MVC3和ASP.Net执行302重定向?

我在一个应用程序中使用带有C#的Razor,HTML5,MVC3,在用户点击链接后,我打开一个新窗口,进行一些处理,然后想要将带有302状态代码的窗口重定向到链接.

谢谢.

redirect http-status-code-302 c#-4.0 asp.net-mvc-3

3
推荐指数
1
解决办法
6599
查看次数

由于 HTTP 302,无法使用 Python 检索经过 NTLM 身份验证的网页

任何人都可以帮助我使用下面的 python 代码吗?这是一些开源,我为自己的使用做了一些修改。我正在尝试从运行 NTLM 身份验证的 Windows 服务器访问网页。起初我的问题是保持持久连接,这样我就不会收到 http 401 错误。现在我已经解决了这个问题,但是发生的情况是我收到一个 http 302 重定向错误以及一个在响应的 set-cookie 中发回的 cookie。因此我添加了一个 cookie 处理程序,但这并没有做任何事情。此外,从服务器返回的“位置”字段包含我首先提交的原始 URL。我不明白这个。为什么从服务器发回用于重定向的位置字段与我提交的 URL 完全相同?!

import urllib2
import httplib, socket 
import cookielib
import ntlm 
from ntlm import ntlm 

class AbstractNtlmAuthHandler: 

   httplib.HTTPConnection.debuglevel = 1 
   url1 = ""

   def __init__(self, password_mgr=None): 
      if password_mgr is None: 
         password_mgr = HTTPPasswordMgr() 
      self.passwd = password_mgr 
      self.add_password = self.passwd.add_password 

    def http_error_authentication_required(self, auth_header_field, req, fp, headers): 
      auth_header_value = headers.get(auth_header_field, None) 
      if auth_header_field: 
         if 'ntlm' in auth_header_value.lower(): 
         if auth_header_value is not None and …
Run Code Online (Sandbox Code Playgroud)

python authentication redirect ntlm http-status-code-302

3
推荐指数
1
解决办法
2469
查看次数

302重定向仍在尝试运行原始请求

我们有一段代码可以检测旧URL并执行重定向,如下所示:

Response.Clear();
Response.StatusCode = 301;
Response.Status = "301 Moved Permanently";
try
{
    Response.AddHeader("Location", MyLink.GetFullPath());
} catch
{
    Response.StatusCode = 302;
    Response.Status = "302 Moved Temporarily";
    Response.AddHeader("Location", "/");
}
Response.End();
Run Code Online (Sandbox Code Playgroud)

本质上发生的是尝试301永久重定向,如果不成功则将"302 Moved Temporarily"抛出到默认主页.

问题:我遇到的问题如下.如果输入了URL(例如"/ product/ABC123").301重定向失败URL和302重定向在catch被执行,但是原来的URL("/产物/ ABC123")仍然在背景中执行.当我在调试器中运行网站时,302重定向工作正常并且默认主页出现,然后半秒后执行补充页面并由于原始URL为no而出现服务器500错误更长的可接受

我的问题如下:如何完全停止原始请求,让302重定向完成它需要做的事情.我试过"HttpContext.ApplicationInstance.CompleteRequest();" 在"Response.End()"下面,但它没有停止原始请求.

编辑:重定向代码正在从Controller类的Index方法执行.

c# asp.net redirect http-status-code-302 asp.net-mvc-3

3
推荐指数
1
解决办法
1659
查看次数

302使用AJAX发布请求进行重定向:

我正在为Web应用程序实现注销功能。我有一个函数,当用户单击注销按钮时会调用该函数。

$.post(window.location.pathname + '/logout');
Run Code Online (Sandbox Code Playgroud)

注销服务仅适用于发布。

发生的是:

  1. 302状态按预期返回,位置为:http : //myapp.com/logout.html
  2. 显然,jquery ajax调用只是从那里接起,然后立即向该位置发出GET请求。
  3. GET请求返回正确的html,但是返回AJAX样式,浏览器未加载重定向页面

我想发生的是:

  1. 302状态按预期返回,位置为:http : //myapp.com/logout.html
  2. 浏览器重定向到给定位置

javascript ajax jquery http-status-code-302

3
推荐指数
1
解决办法
3336
查看次数

PHP按图搜索谷歌cURL返回302移动

我正在尝试获取一个简单的字符串,其中包含我用逐个图像搜索的图像的描述.所以我设置了search_by_google.php页面:

    <?php
$url = $_REQUEST['url'];

if(empty($_REQUEST['raw'])){
$raw = false;
}
else{
$raw = true;
}
echo fetch_google($url, $raw);

function fetch_google($u, $raw, $terms="sample search",$numpages=1,$user_agent='Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0')
{

    $ch = curl_init();
    $url = 'http://www.google.com/imghp?hl=en&tab=wi';
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
    curl_setopt ($ch, CURLOPT_HEADER, TRUE);
    curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt ($ch, CURLOPT_VERBOSE,true);
    curl_setopt ($ch, CURLOPT_REFERER, 'http://www.google.com/');
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,120);
    curl_setopt ($ch, CURLOPT_TIMEOUT,120);
    curl_setopt ($ch, CURLOPT_MAXREDIRS,10);
    curl_setopt ($ch, CURLOPT_COOKIEFILE,"./cookie.txt");
    curl_setopt ($ch, CURLOPT_COOKIEJAR,"./cookie.txt"); …
Run Code Online (Sandbox Code Playgroud)

php curl http-status-code-302 google-image-search

3
推荐指数
2
解决办法
4994
查看次数

从 url 获取文件大小

我遇到了这个 URL url的问题, 它是一个 302 url,当你在 brwoser http://mp3goo.io/ 中运行时它会重定向到这个站点,但是当你在下载管理器上发布它时,它显示 10 mb 文件,我下载并工作美好的。我检查了我的 android 代码,它说 -1 内容长度如何获取文件大小,如下载管理器 图像

android http filesize httpurlconnection http-status-code-302

3
推荐指数
1
解决办法
8200
查看次数

在SSL重定向中,document.referrer在firefox和chrome中为空

javascript中的document.referrer在使用Firefox和Chrome中的F5负载均衡器从302重定向从http到https时是空白的,但在IE中显示.有没有理由这样或一种方法来检测推荐人?

javascript ssl google-chrome referrer http-status-code-302

2
推荐指数
1
解决办法
3748
查看次数

PHP header(); 可靠性

如果我不希望他们能够访问某个页面,我需要重定向用户.header('Location: ../acc/login.php');例如,可靠性如何?浏览器可以忽略302错误,这是正确的方法吗?提前致谢!

php redirect http-status-code-302

2
推荐指数
1
解决办法
831
查看次数

Flutter-处理POST请求中的状态码302

我正在尝试使用postFlutter 发送带有DIO包装的请求。

这是请求:

getSessionId() async {

  var csrf = await getCsrftoken();

  var dio = new Dio(new Options(
      baseUrl: "http://xxxxxxx/accounts/login/",
      connectTimeout: 5000,
      receiveTimeout: 100000,
      // 5s
      headers: {
        'Cookie': "csrftoken=" + csrf
      },
      contentType: ContentType.JSON,
      // Transform the response data to a String encoded with UTF8.
      // The default value is [ResponseType.JSON].
      responseType: ResponseType.PLAIN
  ));

  var response;
  response = await dio.post("http://xxxxxxx/accounts/login/",
    data: {
      "username": "xxxxx",
      "password": "xxxxx",
      "csrfmiddlewaretoken" : csrf
    },
    options: new Options(
        contentType: ContentType.parse("application/x-www-form-urlencoded")),
  ); …
Run Code Online (Sandbox Code Playgroud)

post request http-status-code-302 dart flutter

2
推荐指数
3
解决办法
4719
查看次数