C# 我得到302重定向多次,直到我达到最大重定向
在我的网页中,每种语言都有不同的URL。主要语言是西班牙语,例如,如果在西班牙语中我有以下内容:www.mywebpage.com/coche,在英语中我有以下内容:www.mywebpage.com/en/car 问题是,我得到302状态代码,直到我达到最大数量的重定向时,我使用的英语链接和西班牙语它工作得很好(状态代码200)。我看不出我用西班牙语或英语来获取正确的url有什么不同,所以我不明白为什么会发生这种情况 由于这种情况发生在网页的所有页面上,我真的不知道在这里应该放什么样的代码。我真的不知道它在哪里失败了。我设置了一些断点并尝试进行调试,但我没有看到一个地方在一次又一次地进行调试 在这里,我详细介绍了使用英文url时发生的情况:C# 我得到302重定向多次,直到我达到最大重定向,c#,asp.net,redirect,C#,Asp.net,Redirect,在我的网页中,每种语言都有不同的URL。主要语言是西班牙语,例如,如果在西班牙语中我有以下内容:www.mywebpage.com/coche,在英语中我有以下内容:www.mywebpage.com/en/car 问题是,我得到302状态代码,直到我达到最大数量的重定向时,我使用的英语链接和西班牙语它工作得很好(状态代码200)。我看不出我用西班牙语或英语来获取正确的url有什么不同,所以我不明白为什么会发生这种情况 由于这种情况发生在网页的所有页面上,我真的不知道在这里应该放什么样的代码。我
1. REQUESTING: http://www.mywebpage.com/en/rental/camper-vans/barcelona
GET /en/rental/camper-vans/barcelona HTTP/1.1
Accept: */*
Accept-Encoding: gzip
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
Host: www.mywebpage.com
Connection: Keep-Alive
SERVER RESPONSE: 302 Found
Cache-Control: private
Content-Type: text/html; charset="utf-8"
Location: /en/rental/camper-vans/barcelona
Server: Microsoft-IIS/7.5
Set-Cookie: ASP.NET_SessionId=f0dr1jnqq2qa4lm1jftn5o40;
path=/; HttpOnly
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 03 Jun 2015 10:48:31 GMT
Content-Length: 149
Redirecting to http://www.mywebpage.com/en/rental/camper-vans/barcelona ...
2. REQUESTING: http://www.mywebpage.com/en/rental/camper-vans/barcelona
GET /en/rental/camper-vans/barcelona HTTP/1.1
Accept: */*
Accept-Encoding: gzip
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
Host: www.mywebpage.com
Connection: Keep-Alive
SERVER RESPONSE: 302 Found
Cache-Control: private
Content-Type: text/html; charset="utf-8"
Location: /en/rental/camper-vans/barcelona
Server: Microsoft-IIS/7.5
Set-Cookie: ASP.NET_SessionId=slqb1bj3frbj4qaxlds3lt0r;
path=/; HttpOnly
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 03 Jun 2015 10:48:32 GMT
Content-Length: 149
Redirecting to http://www.mywebpage.com/en/rental/camper-vans/barcelona ...
3. REQUESTING: http://www.mywebpage.com/en/rental/camper-vans/barcelona
GET /en/rental/camper-vans/barcelona HTTP/1.1
Accept: */*
Accept-Encoding: gzip
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
Host: www.mywebpage.com
Connection: Keep-Alive
SERVER RESPONSE: 302 Found
Cache-Control: private
Content-Type: text/html; charset="utf-8"
Location: /en/rental/camper-vans/barcelona
Server: Microsoft-IIS/7.5
Set-Cookie: ASP.NET_SessionId=kgl4jgtiykww0jzc0eto4q0x;
path=/; HttpOnly
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 03 Jun 2015 10:48:32 GMT
Content-Length: 149
Redirecting to http://www.mywebpage.com/en/rental/camper-vans/barcelona ...
4. REQUESTING: http://www.mywebpage.com/en/rental/camper-vans/barcelona
GET /en/rental/camper-vans/barcelona HTTP/1.1
Accept: */*
Accept-Encoding: gzip
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
Host: www.mywebpage.com
Connection: Keep-Alive
SERVER RESPONSE: 302 Found
Cache-Control: private
Content-Type: text/html; charset="utf-8"
Location: /en/rental/camper-vans/barcelona
Server: Microsoft-IIS/7.5
Set-Cookie: ASP.NET_SessionId=evphastef4ccmydel4zxfdvp;
path=/; HttpOnly
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 03 Jun 2015 10:48:32 GMT
Content-Length: 149
Redirecting to http://www.mywebpage.com/en/rental/camper-vans/barcelona ...
5. REQUESTING: http://www.mywebpage.com/en/rental/camper-vans/barcelona
GET /en/rental/camper-vans/barcelona HTTP/1.1
Accept: */*
Accept-Encoding: gzip
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
Host: www.mywebpage.com
Connection: Keep-Alive
SERVER RESPONSE: 302 Found
Cache-Control: private
Content-Type: text/html; charset="utf-8"
Location: /en/rental/camper-vans/barcelona
Server: Microsoft-IIS/7.5
Set-Cookie: ASP.NET_SessionId=2a5oz1cxf1ajcpzig3k4mpjv;
path=/; HttpOnly
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 03 Jun 2015 10:48:32 GMT
Content-Length: 149
Redirecting to http://www.mywebpage.com/en/rental/camper-vans/barcelona ...
6. REQUESTING: http://www.mywebpage.com/en/rental/camper-vans/barcelona
GET /en/rental/camper-vans/barcelona HTTP/1.1
Accept: */*
Accept-Encoding: gzip
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
Host: www.mywebpage.com
Connection: Keep-Alive
SERVER RESPONSE: 302 Found
Cache-Control: private
Content-Type: text/html; charset="utf-8"
Location: /en/rental/camper-vans/barcelona
Server: Microsoft-IIS/7.5
Set-Cookie: ASP.NET_SessionId=lnmxt4jabm2pjztzvr5quajv;
path=/; HttpOnly
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 03 Jun 2015 10:48:33 GMT
Content-Length: 149
下面是我用西班牙语时发生的情况:
1. REQUESTING: http://www.mywebpage.com/alquilar/furgonetas-camper/barcelona
GET /alquilar/furgonetas-camper/barcelona HTTP/1.1
Accept: */*
Accept-Encoding: gzip
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
Host: www.mywebpage.com
Connection: Keep-Alive
SERVER RESPONSE: 200 OK
Cache-Control: private, no-cache="Set-Cookie"
Content-Type: text/html; charset="utf-8"
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Set-Cookie: ASP.NET_SessionId=2yjzrmhrbzynnegjn3ch5tqf;
path=/; HttpOnly
Set-Cookie: cookiePolicy=1;
expires="Tue, 03-Jun-2025 10:50:09 GMT"; path=/
Set-Cookie: .ASPXAUTH=; expires="Mon, 11-Oct-1999 22:00:00 GMT";
path=/; HttpOnly
X-Powered-By: ASP.NET
Date: Wed, 03 Jun 2015 10:50:10 GMT
Content-Length: 107767
编辑:
我继续试图了解发生了什么,我发现了更多的东西,我放在这个线程中,以使问题更准确地说明发生了什么:global.asax.cs中是否有代码来检查区域性以加载正确的资源字符串?我对每种语言使用以下代码
oUrlResolver=new UrlResolver(pLanguage,new local.ServiceClient().GetPageURL(pLanguage));
然后是我们从那里得到的内容(基本上是每种语言的URL列表)您可以创建不同的URL。您可以在ServiceClient/GetPageUrl方法中设置一个断点,看看请求是否有差异。或者,只需传入一个硬编码的pLanguage值,看看它是否有任何更改。不,这不会是问题,因为它到达了正确的页面,并且实际上是在获取最大重定向数之后页面加载正确。因此url本身工作正常。之前我们检查了global.asax url创建。