Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
GeneralRe: Tracing association application Pin
Muammar©5-Jul-09 11:00
Muammar©5-Jul-09 11:00 
Questionuse methods at a WebService in Win app.. Pin
Mtyb5-Jul-09 5:41
Mtyb5-Jul-09 5:41 
AnswerRe: use methods at a WebService in Win app.. Pin
dan!sh 5-Jul-09 5:49
professional dan!sh 5-Jul-09 5:49 
GeneralRe: use methods at a WebService in Win app.. Pin
Mtyb5-Jul-09 5:54
Mtyb5-Jul-09 5:54 
GeneralRe: use methods at a WebService in Win app.. Pin
dan!sh 5-Jul-09 6:03
professional dan!sh 5-Jul-09 6:03 
GeneralRe: use methods at a WebService in Win app.. Pin
Mtyb5-Jul-09 7:04
Mtyb5-Jul-09 7:04 
GeneralRe: use methods at a WebService in Win app.. Pin
dan!sh 5-Jul-09 7:50
professional dan!sh 5-Jul-09 7:50 
QuestionHTTP Post Pin
Endien5-Jul-09 5:23
Endien5-Jul-09 5:23 
Hi, suppose i have an imaginary web address like this with all the query parameter:
http://sokim.seltekom.com/sokim/index.php?do=queryWrite.rewrite&varA=89898&post=1&edat=02-07-2009

I'm using a source code from http://blog.brezovsky.net/
(How to Post data in C# . NET HttpWebRequest)

This is the code :

public static string Post(string url, string data)
{
string vystup = null;
try
{
//Our postvars
byte[] buffer = Encoding.ASCII.GetBytes(data);
//Initialisation, we use localhost, change if appliable
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(url);
//Our method is post, otherwise the buffer (postvars) would be useless
WebReq.Method = "POST";
//We use form contentType, for the postvars.
WebReq.ContentType = "application/x-www-form-urlencoded";
//The length of the buffer (postvars) is used as contentlength.
WebReq.ContentLength = buffer.Length;
//We open a stream for writing the postvars
Stream PostData = WebReq.GetRequestStream();
//Now we write, and afterwards, we close. Closing is always important!
PostData.Write(buffer, 0, buffer.Length);
PostData.Close();
//Get the response handle, we have no true response yet!
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
//Let's show some information about the response
Console.WriteLine(WebResp.StatusCode);
Console.WriteLine(WebResp.Server);
//Stream s = WebResp.GetResponseStream();
//StreamReader sr = new StreamReader(s);

//Now, we read the response (the string), and output it.
Stream Answer = WebResp.GetResponseStream();
StreamReader _Answer = new StreamReader(Answer);
vystup = _Answer.ReadToEnd();

//Console.ReadLine();

//Congratulations, you just requested your first POST page, you
//can now start logging into most login forms, with your application
//Or other examples.
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return vystup.Trim() + "\n";

}


This is what i do:
static void Main(string[] args)
{
Console.Write(Post("http://sokim.seltekom.com/sokim/index.php",
"?do=queryWrite.rewrite&varA=89898&post=1&edat=02-07-2009"));
Console.ReadLine();
}

The problem is, the Console always give me the login page source code. I think maybe it's because of wrong url or data pass to the function. But after i try many combination (like remove the '?' sign) it keep give me the login page html source.

For information, the web site has a login page where i must enter user id and password
and i have privilege to access it.

Before i run the above code, i manually sign in to the web site (i think so i can have session registered on the server). After that then i run the above code.

What i'm trying to do is, pull the data from the web page on html format, then with a few string function to get the actual data i need from the html source code.
It has many link inside that it will exhausted to do it manually.
I want make a program to pull the data out and save it to my database.

Can anyone help?
AnswerRe: HTTP Post Pin
Rozis5-Jul-09 11:30
Rozis5-Jul-09 11:30 
GeneralRe: HTTP Post Pin
Endien5-Jul-09 15:08
Endien5-Jul-09 15:08 
GeneralRe: HTTP Post Pin
Rozis6-Jul-09 11:23
Rozis6-Jul-09 11:23 
GeneralRe: HTTP Post Pin
Endien6-Jul-09 14:06
Endien6-Jul-09 14:06 
QuestionAuto updating application Pin
Rajesh_K_Sharma5-Jul-09 4:53
Rajesh_K_Sharma5-Jul-09 4:53 
AnswerRe: Auto updating application Pin
harold aptroot5-Jul-09 5:30
harold aptroot5-Jul-09 5:30 
AnswerRe: Auto updating application Pin
dan!sh 5-Jul-09 5:31
professional dan!sh 5-Jul-09 5:31 
QuestionExport to Excel From Data Grid In C# Windows Application Pin
ManojKumar195-Jul-09 3:52
ManojKumar195-Jul-09 3:52 
AnswerRe: Export to Excel From Data Grid In C# Windows Application Pin
Christian Graus5-Jul-09 4:09
protectorChristian Graus5-Jul-09 4:09 
AnswerRe: Export to Excel From Data Grid In C# Windows Application Pin
Henry Minute5-Jul-09 4:09
Henry Minute5-Jul-09 4:09 
AnswerRe: Export to Excel From Data Grid In C# Windows Application Pin
dan!sh 5-Jul-09 5:24
professional dan!sh 5-Jul-09 5:24 
GeneralRe: Export to Excel From Data Grid In C# Windows Application Pin
ManojKumar195-Jul-09 6:39
ManojKumar195-Jul-09 6:39 
AnswerRe: Export to Excel From Data Grid In C# Windows Application Pin
FilipKrnjic6-Jul-09 0:22
FilipKrnjic6-Jul-09 0:22 
GeneralRe: Export to Excel From Data Grid In C# Windows Application Pin
ManojKumar196-Jul-09 6:23
ManojKumar196-Jul-09 6:23 
Generalrequest for 70-526 Pin
2222222222225-Jul-09 3:26
2222222222225-Jul-09 3:26 
GeneralRe: request for 70-526 Pin
Alan N5-Jul-09 3:44
Alan N5-Jul-09 3:44 
GeneralRe: request for 70-526 Pin
OriginalGriff5-Jul-09 3:54
mveOriginalGriff5-Jul-09 3:54 

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.