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

C#

 
Questionteking binary files as a input for client windowes application from a website Pin
umr124-Apr-09 20:35
umr124-Apr-09 20:35 
AnswerRe: teking binary files as a input for client windowes application from a website Pin
Bharat Jain24-Apr-09 22:46
Bharat Jain24-Apr-09 22:46 
AnswerRe: teking binary files as a input for client windowes application from a website Pin
Giorgi Dalakishvili24-Apr-09 23:00
mentorGiorgi Dalakishvili24-Apr-09 23:00 
Questionhow to get a list of computer names in LAN Pin
Vinziee24-Apr-09 19:04
Vinziee24-Apr-09 19:04 
AnswerRe: how to get a list of computer names in LAN Pin
Bharat Jain24-Apr-09 22:37
Bharat Jain24-Apr-09 22:37 
GeneralRe: how to get a list of computer names in LAN Pin
Bharat Jain24-Apr-09 22:38
Bharat Jain24-Apr-09 22:38 
QuestionInvoking "click" event on buttons using webBrowser Pin
labdakos24-Apr-09 19:04
labdakos24-Apr-09 19:04 
Questionreddit.com bot Pin
yogesh_softworld12324-Apr-09 13:46
yogesh_softworld12324-Apr-09 13:46 
dear sir,
i am trying to access reddit.com through c# code.
i am using this code:


public void Prepare_Url()
{
try
{
string response = Send_Request("http://www.reddit.com", null);
string postdata ="op=login-main&user=yogeshyahoo&passwd=yogesh&id=%23login_login-main";
response = Send_Request("http://www.reddit.com", postdata);
txtResponse.Text = response;


}
catch (Exception ex)
{
Console.WriteLine("Exception" + ex.Message);
}
}


public string Send_Request(string link, string post_data)
{
//try
//{

string url = string.Format(link);
HttpWebRequest request = (HttpWebRequest )WebRequest.Create(url);

request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.20) Gecko/20081217 Firefox/2.0.0.20";
request.Method = "GET";
request.Accept = "text/xml,application/xml,application/xhtml+xml,text/html,application/json, text/javascript;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";

request.KeepAlive = true;

request.ContentType = @"application/x-www-form-urlencoded";
request.Referer = string.Format("http://www.reddit.com");
request.CookieContainer = new CookieContainer();
request.CookieContainer.Add(cookies);
request.Timeout = 600000;
request.AllowAutoRedirect = false;
//equest.Credentials = new NetworkCredential("yogeshyahoo","yogesh");
request.PreAuthenticate = true;

if (post_data != null)
{//post the data to the desired link
string postData = post_data;
request.Method = "POST";
byte[] postBuffer = System.Text.Encoding.GetEncoding(1252).GetBytes(postData);
Stream postDataStream = request.GetRequestStream();
postDataStream.Write(postBuffer, 0, postBuffer.Length);
postDataStream.Close();
}
string s;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
cookies.Add(response.Cookies);
Encoding enc = System.Text.Encoding.UTF8;
StreamReader sr = new StreamReader(response.GetResponseStream(), enc, true);
s=sr.ReadToEnd();
return s;
// }
//catch (Exception ex)
//{
// MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Console.WriteLine(ex.Message);

// return string.Empty;
//}

}



this code is working for url:www.reddit.com correctly.
ok its ok

but for login i am not getting correct url (Live http header software plugin in firfox)

i am getting www.reddit.com/api/login/<<username>>

but this is not working

im geting error. 404 page not found.


could you please give me idea.

yogesh

Question[Message Deleted] Pin
mdunderwood24-Apr-09 13:02
mdunderwood24-Apr-09 13:02 
GeneralRe: Need assistance with a Producer/Consumer Queue logic where the Consumer can create a limited number of worker threads Pin
harold aptroot24-Apr-09 13:38
harold aptroot24-Apr-09 13:38 
AnswerRe: Need assistance with a Producer/Consumer Queue logic where the Consumer can create a limited number of worker threads Pin
Giorgi Dalakishvili24-Apr-09 22:59
mentorGiorgi Dalakishvili24-Apr-09 22:59 
Questionbluetooth stacks Pin
akinwaadeolu24-Apr-09 12:06
akinwaadeolu24-Apr-09 12:06 
QuestionWCF Question Pin
NETLearning24-Apr-09 11:58
NETLearning24-Apr-09 11:58 
AnswerRe: WCF Question Pin
Hesham Amin24-Apr-09 12:33
Hesham Amin24-Apr-09 12:33 
GeneralWCF Question Pin
NETLearning25-Apr-09 6:13
NETLearning25-Apr-09 6:13 
GeneralRe: WCF Question Pin
Hesham Amin25-Apr-09 23:04
Hesham Amin25-Apr-09 23:04 
QuestionFormatting data in a datagridview Pin
bwood202024-Apr-09 9:23
bwood202024-Apr-09 9:23 
QuestionMulti Column display ina listbox Pin
edlanka24-Apr-09 9:07
edlanka24-Apr-09 9:07 
AnswerRe: Multi Column display ina listbox Pin
DaveyM6924-Apr-09 9:09
professionalDaveyM6924-Apr-09 9:09 
GeneralRe: Multi Column display ina listbox Pin
edlanka24-Apr-09 9:39
edlanka24-Apr-09 9:39 
GeneralRe: Multi Column display ina listbox Pin
Dan Neely24-Apr-09 9:49
Dan Neely24-Apr-09 9:49 
QuestionClosing DialogBox from other application Pin
Papi83dm24-Apr-09 7:47
Papi83dm24-Apr-09 7:47 
QuestionRemoving bytes from an exe file..... is it possible? Pin
Rajdeep.NET is BACK24-Apr-09 6:15
Rajdeep.NET is BACK24-Apr-09 6:15 
AnswerRe: Removing bytes from an exe file..... is it possible? Pin
musefan24-Apr-09 6:36
musefan24-Apr-09 6:36 
GeneralRe: Removing bytes from an exe file..... is it possible? Pin
Rolando CC24-Apr-09 7:40
professionalRolando CC24-Apr-09 7:40 

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.