POST w C#   Leave a comment

  1. How to Post data in C# . NET HttpWebRequest – http://blog.brezovsky.net/
  2. http://maciej-progtech.blogspot.com/2010/04/jak-uczyc-sie-c-pl.html
  3. http://maciej-progtech.blogspot.com/2009/07/blog-c-net-czyli-moj-mini-przewodnik-po.html
  4. Kursy programowania – http://www.eggheadcafe.com/tutorials/aspnet/5261083e-6e03-4b25-8728-fc3cf6855293/free-online-courses-available-for-eggheadcafecom-users.aspx
  5. http://www.eggheadcafe.com/community/aspnet/2/10016302/how-i-send-xml-data-using-http-post-with-basic-authentication-using-c.aspx
  6. Na mS Social – http://social.msdn.microsoft.com/Forums/en-US/ncl/thread/ced36440-2ea8-4b40-9c94-8007eb02ffba – b.ciekawe
  7. http://stackoverflow.com/questions/1127223/c-ssl-basic-access-authentication
  8. http://aspnet.4guysfromrolla.com/articles/122204-1.aspx
  9. Rick Strahl
  10. http://aspnet.4guysfromrolla.com/articles/102605-1.aspx:
  11. Dim req as New WebClient()

    Dim myCache As New CredentialCache()
    myCache.Add(New Uri(URL), "Basic", _
                New NetworkCredential(Username, Password))

    req.Credentials = myCache

    Dim results as String
    results = System.Encoding.UTF8.GetString(req.DownloadData(URL))

  12. http://www.daniweb.com/forums/thread282750.html
  13. string uri = string.Empty, user = string.Empty, password = string.Empty, postData = string.Empty, responseData = string.Empty;
                string encodedAuthorization = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(user + ":" + password));
    HttpWebRequest webRequest = WebRequest.Create(uri) as HttpWebRequest;
    webRequest.Method = "POST";
    webRequest.ContentType = "application/x-www-form-urlencoded";
    webRequest.Headers = new WebHeaderCollection();
    webRequest.Headers.Add("Authorization: Basic "+encodedAuthorization);

    using (StreamWriter rw = new StreamWriter(webRequest.GetRequestStream()))
    {
                rw.Write(postData);
    }

    using (StreamReader sr = new StreamReader(webRequest.GetResponse().GetResponseStream()))
    {
                responseData = sr.ReadToEnd();
    } // z http://fravelgue.wordpress.com/2010/02/10/basic-authentication-en-http-post/

    Inne (z Note)

    public void test(Uri URL)
                    {
                            HttpWebRequest WRequest;
                            HttpWebResponse WResponse;
                            //preAuth the request
                            // You can add logic so that you only pre-authenticate the very first request.
                            // You should not have to pre-authenticate each request.
                            WRequest = (HttpWebRequest)HttpWebRequest.Create(URL);
                            // Set the username and the password.
                            WRequest.Credentials = new NetworkCredential(user, password);
                            WRequest.PreAuthenticate = true;
                            WRequest.UserAgent = "Upload Test";
                            WRequest.Method = "HEAD";
                            WRequest.Timeout = 10000;
                            WResponse = (HttpWebResponse)WRequest.GetResponse();
                            WResponse.Close();
                            // Make the real request.
                            WRequest = (HttpWebRequest)HttpWebRequest.Create(URL);
                            // Set the username and the password.
                            WRequest.Credentials = new NetworkCredential(user, password);
                            WRequest.PreAuthenticate = true;
                            WRequest.UserAgent = "Upload Test";
                            WRequest.Method = "POST";
                            WRequest.AllowWriteStreamBuffering = false;
                            WRequest.Timeout = 10000;
                            FileStream ReadIn = new FileStream("c:\testuploadfile.txt", FileMode.Open, FileAccess.Read);
                            ReadIn.Seek(0, SeekOrigin.Begin); // Move to the start of the file.
                            WRequest.ContentLength = ReadIn.Length; // Set the content length header to the size of the file.
                            Byte[] FileData = new Byte[ReadIn.Length]; // Read the file in 2 KB segments.
                            int DataRead = 0;
                            Stream tempStream = WRequest.GetRequestStream();
                            do
                            {
                                    DataRead = ReadIn.Read(FileData,0,2048);
                                    if (DataRead > 0) //we have data
                                    {
                                            tempStream.Write(FileData,0,DataRead);
                                            Array.Clear(FileData,0, 2048); // Clear the array.
                                    }
                            }while(DataRead > 0);
                            WResponse = (HttpWebResponse)WRequest.GetResponse();
                            // Read your response data here.
                            // Close all streams.
                            ReadIn.Close();
                            tempStream.Close();
                            WResponse.Close();
                    }

    Pasted from <http://support.microsoft.com/kb/908573>

    $req .= "&cmd=_initiate_query";
    $header = "POST /someendpoint HTTP/1.1rn".
    "Host:example.comn".
    "Content-Type: application/x-www-form-urlencodedrn".
    "User-Agent: PHP-Codern".
    "Content-Length: " . strlen($req) . "rn".
    "Connection: closernrn";
    $fp = fsockopen (‚ssl://example.com’, 443, $errno, $errstr, 30);
    if (!$fp) {
    // HTTP ERROR
    } else {
        fputs ($fp, $header . $req);
    while (!feof($fp)) {
            $result .= fgets ($fp, 128);
        }
        fclose ($fp);

    Pasted from <http://stackoverflow.com/questions/1198756/issue-form-post-request-from-php-using-http-basic-authentication>

    Lub

    http://www.peej.co.uk/articles/http-auth-with-html-forms.html

    http://stackoverflow.com/questions/1652178/basic-authentication-with-xmlhttprequest

    http://curl.haxx.se/docs/httpscripting.html

Posted 6 Lipiec 2010 by marekwmsdn in Bez kategorii

Skomentuj

Wprowadź swoje dane lub kliknij jedną z tych ikon, aby się zalogować:

Logo WordPress.com

Komentujesz korzystając z konta WordPress.com. Log Out / Zmień )

Zdjęcie z Twittera

Komentujesz korzystając z konta Twitter. Log Out / Zmień )

Facebook photo

Komentujesz korzystając z konta Facebook. Log Out / Zmień )

Google+ photo

Komentujesz korzystając z konta Google+. Log Out / Zmień )

Connecting to %s

%d bloggers like this: