Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
GeneralRe: Automatically Display Expire Date Pin
Colin Angus Mackay28-Jul-04 0:31
Colin Angus Mackay28-Jul-04 0:31 
GeneralRe: Automatically Display Expire Date Pin
ASGill28-Jul-04 7:58
ASGill28-Jul-04 7:58 
GeneralRe: Automatically Display Expire Date Pin
Roman Rodov28-Jul-04 15:50
Roman Rodov28-Jul-04 15:50 
Questiondouble -> float : casting or Convert.ToSingle ? Pin
crushinghellhammer27-Jul-04 13:13
crushinghellhammer27-Jul-04 13:13 
AnswerRe: double -> float : casting or Convert.ToSingle ? Pin
mikker_12327-Jul-04 22:56
mikker_12327-Jul-04 22:56 
AnswerRe: double -> float : casting or Convert.ToSingle ? Pin
Nick Parker28-Jul-04 2:56
protectorNick Parker28-Jul-04 2:56 
GeneralCreating MDB & MDW with ADOX and C# Pin
ulrich_v27-Jul-04 10:49
ulrich_v27-Jul-04 10:49 
GeneralProtocol Violation using HttpWebRequest Pin
Amir Zicherman27-Jul-04 9:50
Amir Zicherman27-Jul-04 9:50 
Hi,

In Visual c# 2005 Express, the code below will throw the following exception when accessing www.amazon.com. This does not happen in older versions of the .NET Framework. Why is this happening? Not sure what the violation here is. Using a different program, I can see that the returned headers by amazon.com look like this:

HTTP/1.1 301 Moved Permanently
Date: Tue, 27 Jul 2004 18:54:05 GMT
Server: Stronghold/2.4.2 Apache/1.3.6 C2NetEU/2412 (Unix) amarewrite/0.1 mod_fastcgi/2.2.12
Set-Cookie: skin=; domain=.amazon.com; path=/; expires=Wed, 01-Aug-01 12:00:00 GMT
Location: http://www.amazon.com:80/exec/obidos/subst/home/home.html
Connection: close
Content-Type: text/plain


EXCEPTION:

at System.Net.HttpWebRequest.CheckFinalStatus(Boolean mustThrow)
at System.Net.HttpWebRequest.GetResponse()
at ProtocolViolation.ProtocolViolation.GetHTML(String url_) in c:\documents a
nd settings\administrator\local settings\application data\temporary projects\con
soleapplication1\program.cs:line 21

CODE:

using System;
using System.Net;

namespace ProtocolViolation
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class ProtocolViolation
{

public static string GetHTML(string url_)
{
HttpWebResponse response = null;
HttpWebRequest request = null;
try
{
request = (HttpWebRequest)(WebRequest.Create(url_));
response = (HttpWebResponse)request.GetResponse();
}
catch (Exception e)
{
Console.WriteLine(e);
}
finally
{
if (response != null)
{
response.Close();
}
request = null;
response = null;
}
return "";
}

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
while (true)
{
GetHTML("http://www.amazon.com:80/exec/obidos/subst/home/home.html");
}
}
}
}



Thanx, amir
GeneralRe: Protocol Violation using HttpWebRequest Pin
Nick Parker27-Jul-04 10:35
protectorNick Parker27-Jul-04 10:35 
GeneralRe: Protocol Violation using HttpWebRequest Pin
Amir Zicherman27-Jul-04 14:23
Amir Zicherman27-Jul-04 14:23 
GeneralRe: Protocol Violation using HttpWebRequest Pin
Nick Parker27-Jul-04 18:05
protectorNick Parker27-Jul-04 18:05 
GeneralRe: Protocol Violation using HttpWebRequest Pin
Amir Zicherman27-Jul-04 18:12
Amir Zicherman27-Jul-04 18:12 
GeneralRe: Protocol Violation using HttpWebRequest Pin
Tom Larsen27-Jul-04 18:39
Tom Larsen27-Jul-04 18:39 
GeneralRe: Protocol Violation using HttpWebRequest Pin
Amir Zicherman27-Jul-04 20:26
Amir Zicherman27-Jul-04 20:26 
GeneralComponents, Mouse Events and Abnormal Shapes Pin
Tristan Rhodes27-Jul-04 6:02
Tristan Rhodes27-Jul-04 6:02 
GeneralRe: Components, Mouse Events and Abnormal Shapes Pin
Gary Thom27-Jul-04 7:26
Gary Thom27-Jul-04 7:26 
GeneralInitialization in web services Pin
pelos27-Jul-04 5:38
pelos27-Jul-04 5:38 
GeneralRe: Initialization in web services Pin
Dave Kreskowiak27-Jul-04 6:42
mveDave Kreskowiak27-Jul-04 6:42 
GeneralRe: Initialization in web services Pin
Nick Parker27-Jul-04 9:28
protectorNick Parker27-Jul-04 9:28 
GeneralCustom VS.NET Wizard query Pin
Michael P Butler27-Jul-04 3:30
Michael P Butler27-Jul-04 3:30 
GeneralRe: Custom VS.NET Wizard query Pin
Heath Stewart27-Jul-04 11:18
protectorHeath Stewart27-Jul-04 11:18 
GeneralRe: Custom VS.NET Wizard query Pin
Michael P Butler28-Jul-04 1:33
Michael P Butler28-Jul-04 1:33 
GeneralActive Directory Exception Pin
vcorn26-Jul-04 20:36
vcorn26-Jul-04 20:36 
GeneralRe: Active Directory Exception Pin
Dave Kreskowiak27-Jul-04 6:38
mveDave Kreskowiak27-Jul-04 6:38 
GeneralRe: Active Directory Exception Pin
vcorn27-Jul-04 19:44
vcorn27-Jul-04 19:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.