473,698 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I am trying to post data with no success

24 New Member
I am trying to post data from C# using the code below. When I run the code with httpwatch running all that gets posted is the button action and .Net eventvalidation and viewstate data. Ideas anyone?

Expand|Select|Wrap|Line Numbers
  1.  
  2.           ASCIIEncoding encoding=new ASCIIEncoding();
  3.            string postData = "subject=test";
  4.            postData += ("&description=test");
  5.            postData += ("&domain=XX"); 
  6.  
  7.             postData += ("DOMAIN_NAME=XX");
  8.             postData += ("&logonDomainName=AD_AUTH");
  9.  
  10.             postData += ("&username=XXX");
  11.             postData += ("&password=XXX");
  12.  
  13.  
  14.  
  15. byte[] data = encoding.GetBytes(postData);
  16.  
  17. // Prepare web request...
  18. HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
  19. myRequest.Method = "POST";
  20. myRequest.ContentType="application/x-www-form-urlencoded";
  21. myRequest.ContentLength = data.Length;
  22. Stream newStream=myRequest.GetRequestStream();
  23. // Send the data.
  24. newStream.Write(data,0,data.Length);
  25. newStream.Close();
  26.  
  27.  
  28. //Get the response handle, we have no true response yet!
  29. HttpWebResponse WebResp = (HttpWebResponse)myRequest.GetResponse();
  30. //Let's show some information about the response
  31. Response.Write(WebResp.StatusCode);
  32. Response.Write(WebResp.Server);
  33.  
  34. //Now, we read the response (the string), and output it.
  35. Stream Answer = WebResp.GetResponseStream();
  36. StreamReader _Answer = new StreamReader(Answer);
  37.  
  38. Response.Write(_Answer.ReadToEnd().Replace("<","&lt;").Replace(">","&gt;"));
  39.  
  40.         }
  41.  
Jun 17 '09 #1
0 1315

Sign in to post your reply or Sign up for a free account.

Similar topics

7
2885
by: Julia | last post by:
Hi, I have a web application running inside an organization and I need to post some data to an asp page sitting outside the organization How do I get failure or success error from the outside page? currently I am using IFrame,but I wonder if I get 404(server down) how do I know I go an error? BTW:since it is an organization i am open to other solution,cause i might be able to install
1
2267
by: audipen | last post by:
Hi, I trap the 'OnBuildProjConfigDone' and perform some custom enhancement to the assembly. I check the 'bool Success' parameter before I perform my step. I go ahead only if 'Success == true" My question is - Is there any way in which I can indicate success or failure of my post build step.. 'Success' is an in-parameter, so I cant set it to false. Also the return type of the handler is void.
7
17877
by: Dica | last post by:
i've used the sample code from msdn to create an encyption/decryption assembly as found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT10.asp i'm able to encrypt and then decrypt data okay as in the following code: // encrypt the data // Encryptor enc = new Encryptor(EncryptionAlgorithm.TripleDes); byte key = Encoding.ASCII.GetBytes("0123456789012345");
12
2661
by: Assaf | last post by:
Hi all, My client is using an online service provider that processes survey responses. After a user fills survey.aspx and presses the OK button, 2 things need to happen: 1. the data has to be posted behind the scenes to the provider's URL (e.g., http://www.surveyprocessingprovider.com/srvy1?field1=response1&field2=response2) 2. the user has to be redirected to thankyou.aspx.
4
1806
by: Jay | last post by:
Hello all, I was wondering if someone can point me to a tutorial that show me how I can set up a web service that can listen for me to send a POST from a client? like so Client sends http POST to http://www.mysite.com/processTheRequest. The data being sent across is XML like so "<request><data>alot of text data that I will manipulate and save to the sql database</data></request>"
5
3785
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public List<RoleData> GetRoles() { return GetRoles(null, false); }
13
4865
by: ragtag99 | last post by:
I posted this on comp.lang.asm.x86, alt.os.development, comp.arch, comp.lang.c++ Im working with windows xp professional, NTFS and programming with MASM, c++ (free compiler) or visual basic 6.0 === question 1 Primarily Im trying to design a program that has full control over a hard disk. What it needs to do is find out what sectors haven't been
1
2108
by: jayesch | last post by:
I am sorry, there is a lot of document available already for this but some how none of it seem to be working for me. I have tried examples for HttpWebRequest/Response but no success. I have a C# client which does not have web interface or any ASP code. Hence I can not access "System.Net.Web.Response" name space or methods. However I still can create WebRequest instance. I have an object that I serialize in an XML file. I need to send that...
6
3124
by: cethie | last post by:
In the code below, DoGet is working very stable. But DoPost throws an uncatcheable InvalidOperationException randomly. I am lost. Any pointers will be of immense help. /* Environment ------------- * NET CF 2.0 * WM 5.0(USA Mobile Pocket PC Emulator) * Windows XP Professional SP2 * VS 2008
0
8676
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8608
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8898
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3051
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.