Click here to Skip to main content
15,896,507 members
Home / Discussions / C#
   

C#

 
QuestionHow to Convert this in C# Pin
majidbhutta3-Sep-05 8:21
majidbhutta3-Sep-05 8:21 
Answer[Message Deleted] Pin
philip_cole3-Sep-05 9:18
philip_cole3-Sep-05 9:18 
AnswerRe: How to Convert this in C# Pin
philip_cole3-Sep-05 9:30
philip_cole3-Sep-05 9:30 
QuestionReflection Emit Pin
Yoyosch3-Sep-05 7:07
Yoyosch3-Sep-05 7:07 
AnswerRe: Reflection Emit Pin
if_mel_yes_else_no3-Sep-05 8:38
if_mel_yes_else_no3-Sep-05 8:38 
QuestionTime change events Pin
monrobot133-Sep-05 6:25
monrobot133-Sep-05 6:25 
AnswerRe: Time change events Pin
if_mel_yes_else_no3-Sep-05 8:29
if_mel_yes_else_no3-Sep-05 8:29 
QuestionHttpWebRequest Timeout Problem Pin
surfman193-Sep-05 4:30
surfman193-Sep-05 4:30 
hi,
i have a problem when i send a HttpRequest!
first i send a request to get the session_id than a login request and after that a other request....
after that i begin with the request for session_id and than the problem arise when i send the login request...
i get a timeout error when i call request.GetRequestStream (); by why!?!

cu

<br />
request for session id:<br />
-----------------------<br />
HttpWebRequest get_request = (HttpWebRequest)WebRequest.Create("https://www.myzone.at/webkeeper/Controller");<br />
get_request.CookieContainer = new CookieContainer();<br />
      <br />
HttpWebResponse get_response = (HttpWebResponse) get_request.GetResponse();<br />
get_response.Cookies = get_request.CookieContainer.GetCookies(get_request.RequestUri);<br />
<br />
String sessionid = "Cookie: ";<br />
sessionid += get_response.Cookies[0].ToString();<br />
<br />
login request:<br />
--------------<br />
HttpRequestResponse login_request = new HttpRequestResponse("https://www.myzone.at/webkeeper/Controller", "POST", "action=login&login=Anmelden&brand=myzone&username=xxxxxx&password=xxxxxxb&x=83&y=13");<br />
login_request.SESSION_ID = sessionid;<br />
login_request.SendRequest();<br />
<br />
<br />
<br />
sendrequest method:<br />
-----------------------------------------<br />
public string SendRequest()<br />
{<br />
    string responseFromServer="";<br />
<br />
    try<br />
    {<br />
        if((RequestMethod.ToUpper() != "GET") && (RequestMethod.ToUpper() != "POST"))<br />
            throw new WebException(RequestMethod+ " is not a valid method.  Use GET or POST.");<br />
<br />
        // Create a request using a URL that can receive a post. <br />
        HttpWebRequest request = (HttpWebRequest) WebRequest.Create(URL);<br />
        // Set the Method property of the request to POST.<br />
                request.Method = RequestMethod;<br />
        // Set the sessionid to the Header<br />
        request.Headers.Add(SessionId);<br />
<br />
        // check if asked to do a POST request, if so then modify <br />
        // the original request as it defaults to a GET method<br />
        if(RequestMethod.ToUpper()=="POST") <br />
        {<br />
            // Create POST data and convert it to a byte array.<br />
            byte[] byteArray = Encoding.UTF8.GetBytes (PostData);<br />
                    <br />
            // Set the ContentType property of the WebRequest.<br />
            request.ContentType = "application/x-www-form-urlencoded";<br />
                    <br />
            // Set the ContentLength property of the WebRequest.<br />
            request.ContentLength = byteArray.Length;<br />
                    <br />
            // Get the request stream.<br />
            Stream requestStream = request.GetRequestStream ();     <------------ here arise the timeout when i send the 2nd login request...<br />
                    <br />
            // Write the data to the request stream.<br />
            requestStream.Write (byteArray, 0, byteArray.Length);<br />
            // Close the Stream object.<br />
            requestStream.Close ();<br />
        }<br />
                <br />
        // Get the response.<br />
        HttpWebResponse response = (HttpWebResponse) request.GetResponse();<br />
        // Get the stream containing content returned by the server.<br />
        Stream dataStream = response.GetResponseStream ();<br />
        // Open the stream using a StreamReader for easy access.<br />
        StreamReader reader = new StreamReader (dataStream);<br />
        // Read the content.<br />
        responseFromServer = "HTTP/" + response.ProtocolVersion + " " + response.StatusDescription + " ";<br />
        responseFromServer += response.Headers.ToString();<br />
<br />
        // Clean up the streams.<br />
        reader.Close ();<br />
        dataStream.Close ();<br />
        response.Close ();<br />
    }<br />
<br />
    catch (WebException e)<br />
    {<br />
        throw CatchHttpExceptions(responseFromServer = e.Message);<br />
    }<br />
    catch (Exception e)<br />
    {<br />
        throw new Exception(responseFromServer = e.Message);<br />
    }<br />
<br />
    return responseFromServer;<br />
}<br />

AnswerRe: HttpWebRequest Timeout Problem Pin
Andy Brummer3-Sep-05 14:21
sitebuilderAndy Brummer3-Sep-05 14:21 
GeneralRe: HttpWebRequest Timeout Problem Pin
surfman193-Sep-05 14:36
surfman193-Sep-05 14:36 
GeneralRe: HttpWebRequest Timeout Problem Pin
Andy Brummer3-Sep-05 17:03
sitebuilderAndy Brummer3-Sep-05 17:03 
GeneralRe: HttpWebRequest Timeout Problem Pin
surfman194-Sep-05 1:23
surfman194-Sep-05 1:23 
QuestionCurciut problem Pin
Niklas Ulvinge3-Sep-05 3:30
Niklas Ulvinge3-Sep-05 3:30 
AnswerRe: Curciut problem Pin
rudy.net3-Sep-05 5:21
rudy.net3-Sep-05 5:21 
GeneralRe: Curciut problem Pin
Niklas Ulvinge3-Sep-05 5:33
Niklas Ulvinge3-Sep-05 5:33 
QuestionNow, how to extract low nibble and high nibble from a byte? Pin
bouli3-Sep-05 3:15
bouli3-Sep-05 3:15 
AnswerRe: Now, how to extract low nibble and high nibble from a byte? Pin
Colin Angus Mackay3-Sep-05 3:21
Colin Angus Mackay3-Sep-05 3:21 
AnswerRe: Now, how to extract low nibble and high nibble from a byte? Pin
Guffa3-Sep-05 6:09
Guffa3-Sep-05 6:09 
QuestionPlease Heeeeeeeeelp: Problem with Pinvoke??? Pin
E6AD3-Sep-05 2:46
E6AD3-Sep-05 2:46 
Questionlooping statement Pin
Anonymous3-Sep-05 1:53
Anonymous3-Sep-05 1:53 
QuestionRe: looping statement Pin
Guffa3-Sep-05 2:10
Guffa3-Sep-05 2:10 
AnswerRe: looping statement Pin
Libor Tinka3-Sep-05 2:42
Libor Tinka3-Sep-05 2:42 
AnswerRe: looping statement Pin
Colin Angus Mackay3-Sep-05 3:23
Colin Angus Mackay3-Sep-05 3:23 
QuestionMy C++ MFC-app into a dll -&gt; to be used in .NET app&#8230; Pin
anderslundsgard3-Sep-05 1:25
anderslundsgard3-Sep-05 1:25 
QuestionHow to concatenate 2 nibbles in 1 byte? Pin
bouli3-Sep-05 1:22
bouli3-Sep-05 1:22 

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.