Click here to Skip to main content
15,915,057 members
Home / Discussions / C#
   

C#

 
QuestionDatabindings Question Pin
Drew McGhie21-Jun-06 12:08
Drew McGhie21-Jun-06 12:08 
AnswerRe: Databindings Question Pin
Edbert P21-Jun-06 14:30
Edbert P21-Jun-06 14:30 
GeneralRe: Databindings Question Pin
Drew McGhie22-Jun-06 3:30
Drew McGhie22-Jun-06 3:30 
QuestionTreeNode image question Pin
likefood21-Jun-06 11:49
likefood21-Jun-06 11:49 
GeneralRe: TreeNode image question Pin
BoneSoft21-Jun-06 11:56
BoneSoft21-Jun-06 11:56 
QuestionIConvertible Error (part deux from previous post) Pin
leckey21-Jun-06 11:39
leckey21-Jun-06 11:39 
AnswerRe: IConvertible Error (part deux from previous post) Pin
led mike21-Jun-06 19:24
led mike21-Jun-06 19:24 
QuestionForm based post with file and data [modified] Pin
Green Goblin21-Jun-06 11:09
Green Goblin21-Jun-06 11:09 
Any takers? I need to do an automated form based post where I will post to another .aspx page over a secure https url. In the form post will be 9 fields of data that are text and one which is a binary file.

A NameValueCollection works like a charm for just the text input fields, but I can not seem to include the file which needs to be a binary format. The NameValueCollection expects a string value for the key pairs. I have examined what .Net provides as far as UploadData, UploadFile and UploadValues. I am using UploadValues because of the NameValueCollection.

Any suggestions on how to post everything at one time? Thanks in advance.

My code is:

int FileLen = this.Filepath.PostedFile.ContentLength;
byte[] FileBinaryData = new byte[FileLen];
HttpPostedFile theFile = this.Filepath.PostedFile;
theFile.InputStream.Read(FileBinaryData, 0,FileLen);

NameValueCollection theCollection = new NameValueCollection();
theCollection.Add("ID", "someid"); -- these values will all be suppiled.
theCollection.Add("PWORD","somepwd");
theCollection.Add("PID", "sometextvalue");
theCollection.Add("FOLDER", "sometextvalue");
theCollection.Add("FILE001", theFile); --this needs to be the binary value
theCollection.Add("TYPE1","sometextvalue");
theCollection.Add("FILE002", "");
theCollection.Add("TYPE2","");
theCollection.Add("INVOICE_NUM", "");
theCollection.Add("TOTAL_FEE","");

string url = ConfigurationSettings.AppSettings["PostingURL"].ToString();
WebClient theRequest = new WebClient();

System.Net.NetworkCredential thecred = new NetworkCredential(ConfigurationSettings.AppSettings["NTLogin"].ToString(), ConfigurationSettings.AppSettings["NTPassword"].ToString(), ConfigurationSettings.AppSettings["Domain"].ToString());
theRequest.Credentials = thecred;

byte[] responseArray = theRequest.UploadValues(url,"POST",theCollection);
string m_ResultText = Encoding.ASCII.GetString(responseArray);
return m_ResultText;


GG


-- modified at 12:02 Wednesday 16th August, 2006

GG
QuestionGeneric class [modified] Pin
torontomouse21-Jun-06 10:46
torontomouse21-Jun-06 10:46 
AnswerRe: Generic class Pin
Josh Smith21-Jun-06 10:52
Josh Smith21-Jun-06 10:52 
GeneralRe: Generic class Pin
torontomouse21-Jun-06 16:43
torontomouse21-Jun-06 16:43 
GeneralRe: Generic class Pin
Josh Smith24-Jun-06 15:33
Josh Smith24-Jun-06 15:33 
AnswerRe: retrieving command line arguments from a file Pin
Judah Gabriel Himango21-Jun-06 11:57
sponsorJudah Gabriel Himango21-Jun-06 11:57 
QuestionHow can I send to back a mdi child window? Pin
User 309585921-Jun-06 10:43
User 309585921-Jun-06 10:43 
Questiondata unbinding relate...urgnt plzz Pin
r_e_h_a_n21-Jun-06 10:33
r_e_h_a_n21-Jun-06 10:33 
AnswerRe: data unbinding relate...urgnt plzz Pin
Edbert P21-Jun-06 14:50
Edbert P21-Jun-06 14:50 
QuestionBiztalk 2004: How to pass database facts from C# code? Pin
pankazmittal21-Jun-06 10:25
pankazmittal21-Jun-06 10:25 
QuestionSQL Express 2005 Dumper for SQL Server 2005 Pin
emran83421-Jun-06 10:14
emran83421-Jun-06 10:14 
AnswerRe: SQL Express 2005 Dumper for SQL Server 2005 Pin
Mark Tutt21-Jun-06 10:50
Mark Tutt21-Jun-06 10:50 
QuestionData Adapter passing by reference to stored procedure Pin
leckey21-Jun-06 9:07
leckey21-Jun-06 9:07 
AnswerRe: Data Adapter passing by reference to stored procedure Pin
Not Active21-Jun-06 9:25
mentorNot Active21-Jun-06 9:25 
GeneralRe: Data Adapter passing by reference to stored procedure [modified] Pin
leckey21-Jun-06 9:28
leckey21-Jun-06 9:28 
GeneralRe: Data Adapter passing by reference to stored procedure Pin
ashishinfra21-Jun-06 20:07
ashishinfra21-Jun-06 20:07 
AnswerRe: Data Adapter passing by reference to stored procedure Pin
Josh Smith21-Jun-06 9:43
Josh Smith21-Jun-06 9:43 
GeneralRe: Data Adapter passing by reference to stored procedure Pin
leckey21-Jun-06 9:47
leckey21-Jun-06 9:47 

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.