Click here to Skip to main content
15,881,882 members
Home / Discussions / C#
   

C#

 
GeneralRe: Fill a datagridview using another Pin
Dave Kreskowiak6-May-13 7:12
mveDave Kreskowiak6-May-13 7:12 
QuestionFetch Data from another website Pin
sandeep Nishad5-May-13 20:40
sandeep Nishad5-May-13 20:40 
AnswerRe: Fetch Data from another website Pin
OriginalGriff5-May-13 22:07
mveOriginalGriff5-May-13 22:07 
AnswerRe: Fetch Data from another website Pin
Clifford Nelson6-May-13 5:38
Clifford Nelson6-May-13 5:38 
QuestionAuto Dial-Up Method not working on 64-bit machine Pin
Edward_Zhao5-May-13 14:40
professionalEdward_Zhao5-May-13 14:40 
AnswerRe: Auto Dial-Up Method not working on 64-bit machine Pin
Garth J Lancaster5-May-13 16:41
professionalGarth J Lancaster5-May-13 16:41 
GeneralRe: Auto Dial-Up Method not working on 64-bit machine Pin
Edward_Zhao8-May-13 20:10
professionalEdward_Zhao8-May-13 20:10 
Questionwebrequest/response live.mail.com Pin
Crispybc5-May-13 12:15
Crispybc5-May-13 12:15 
Hi I have just started a little app to learn about web requests. Basically all I want to do is to login to hotmail via console and return the mail page. here is my code:
C#
using System;
using System.Data;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Web;
using System.Text;



namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {

            var request = (HttpWebRequest)WebRequest.Create("http://login.live.com/");
            

            String email = "test@hotmail.com";
            String password = "password";
            String postString = "login=" + email + "&passwd=" + password;
            CookieCollection cookies = new CookieCollection();

            string url = "http://login.live.com/";
            // Set the request parameters
            request = WebRequest.Create(url) as HttpWebRequest;
            request.Method = "GET";
            request.Referer = url;
            request.KeepAlive = true;
            request.UserAgent = "User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0";
            request.ContentType = "application/x-www-form-urlencoded";
            request.CookieContainer = new CookieContainer();
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            cookies = response.Cookies;
            
    
           
            // Convert the submit string data into the byte array
            Byte[] postData = Encoding.ASCII.GetBytes(postString);
            url = "http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=10&ct=1193552878&rver=4.5.2130.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&id=64855";
            // Set the request parameters
            request = WebRequest.Create(url) as HttpWebRequest;
            request.AllowAutoRedirect = true;
            request.Method = "POST";
            request.Referer = url;
            request.KeepAlive = true;
            request.UserAgent = "User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0";
            request.ContentType = "application/x-www-form-urlencoded";
            request.CookieContainer = new CookieContainer();
            request.CookieContainer.Add(cookies);
            request.ContentLength = postData.Length;

            // Submit the request data
            System.IO.Stream outputStream = request.GetRequestStream();
            request.AllowAutoRedirect = true;
            outputStream.Write(postData, 0, postData.Length);
            outputStream.Close();


            // Get the return data
            
            Console.WriteLine(response.StatusCode);
            Console.WriteLine(response.StatusDescription);
            Console.WriteLine(response.Server);
            Stream dataStream = response.GetResponseStream();
            StreamReader reader = new System.IO.StreamReader(dataStream);
            String responseFromServer = reader.ReadToEnd();
            StreamWriter sw = new StreamWriter("test.html");
            sw.Write(responseFromServer);
            Console.Write(responseFromServer);
            Console.ReadLine();








        }
    }
}


Problem is I keep getting this returned.
<html dir="ltr" lang="EN-US"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=Edge"/><base href="http://login.live.com/pp1450/"/><script type="text/javascript">var PROOF = {};PROOF.Type = {SQSA: 6, CSS: 5, DeviceId: 4, Email: 1, AltEmail: 2, SMS: 3, HIP: 8, Birthday: 9, TOTPAuthenticator: 10, Voice: -3};</script><noscript><meta http-equiv="Refresh" content="0; URL=http://login.live.com/jsDisabled.srf?mkt=EN-US&lc=1033"/>Microsoft account requires JavaScript to sign in. This web browser either does not support JavaScript, or scripts are being blocked.<br /><br />To find out whether your browser supports JavaScript, or to allow scripts, see the browser's online help.</noscript><title>Sign in to your Microsoft account</title><meta name="PageID" content="i5030"/><meta name="SiteID" content="10"/><meta name="ReqLC" content="1033"/><meta name="LocLC" content="1033"/><link rel="shortcut icon" href="http://auth.gfx.ms/14.500.21648.00/favicon.ico?v=2" />


Anyone able to provide some insight?
Thanks.
AnswerRe: webrequest/response live.mail.com Pin
Bernhard Hiller5-May-13 22:04
Bernhard Hiller5-May-13 22:04 
GeneralRe: webrequest/response live.mail.com Pin
Crispybc6-May-13 2:41
Crispybc6-May-13 2:41 
Questionproblem Webservice Pin
azadehrasadi5-May-13 0:12
azadehrasadi5-May-13 0:12 
AnswerRe: problem Webservice Pin
OriginalGriff5-May-13 6:08
mveOriginalGriff5-May-13 6:08 
GeneralRe: problem Webservice Pin
azadehrasadi12-May-13 2:17
azadehrasadi12-May-13 2:17 
GeneralRe: problem Webservice Pin
OriginalGriff12-May-13 2:24
mveOriginalGriff12-May-13 2:24 
GeneralRe: problem Webservice Pin
azadehrasadi12-May-13 18:31
azadehrasadi12-May-13 18:31 
QuestionWEB SERVICES Pin
sonu Ranjan4-May-13 22:16
sonu Ranjan4-May-13 22:16 
AnswerRe: WEB SERVICES Pin
Abhinav S5-May-13 20:37
Abhinav S5-May-13 20:37 
QuestionUSB device being in use Pin
Blubbo3-May-13 5:10
Blubbo3-May-13 5:10 
AnswerRe: USB device being in use Pin
Gerry Schmitz3-May-13 11:54
mveGerry Schmitz3-May-13 11:54 
GeneralRe: USB device being in use Pin
Blubbo8-May-13 8:23
Blubbo8-May-13 8:23 
GeneralRe: USB device being in use Pin
Gerry Schmitz8-May-13 11:12
mveGerry Schmitz8-May-13 11:12 
QuestionIs streamreader slow compared to other text import functions? Pin
turbosupramk33-May-13 3:42
turbosupramk33-May-13 3:42 
AnswerRe: Is streamreader slow compared to other text import functions? Pin
GuyThiebaut3-May-13 4:21
professionalGuyThiebaut3-May-13 4:21 
GeneralRe: Is streamreader slow compared to other text import functions? Pin
turbosupramk33-May-13 4:51
turbosupramk33-May-13 4:51 
AnswerRe: Is streamreader slow compared to other text import functions? Pin
Pete O'Hanlon3-May-13 4:24
mvePete O'Hanlon3-May-13 4:24 

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.