Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
4.00/5 (4 votes)
See more:
Dear all,
I am working on windows application and i need to pass errors generated on a windows application to web site. i think Get/Post method is valid solution.
i need a help.
Any kind of link, suggestion and specially expert advice would be highly appreciated.


Thanks & Regards,
Balkrishna Raut
Posted

Please check the following thread:

http://forums.asp.net/t/1223016.aspx[^]
 
Share this answer
 
Hi,
you can send the errors via post parameters:

string HttpPost (string uri, string parameters)
{ 
   // parameters: name1=value1&name2=value2	
   WebRequest webRequest = WebRequest.Create (uri);
   webRequest.ContentType = "application/x-www-form-urlencoded";
   webRequest.Method = "POST";
   byte[] bytes = Encoding.ASCII.GetBytes (parameters);
   Stream os = null;
   try
   { // send the Post
      webRequest.ContentLength = bytes.Length;   
      os = webRequest.GetRequestStream();
      os.Write (bytes, 0, bytes.Length);         //Send it
   }
   catch (WebException ex)
   {
      MessageBox.Show ( ex.Message, "HttpPost: Request error", 
         MessageBoxButtons.OK, MessageBoxIcon.Error );
   }
   finally
   {
      if (os != null)
      {
         os.Close();
      }
   }
 
   try
   { // get the response
      WebResponse webResponse = webRequest.GetResponse();
      if (webResponse == null) 
         { return null; }
      StreamReader sr = new StreamReader (webResponse.GetResponseStream());
      return sr.ReadToEnd ().Trim ();
   }
   catch (WebException ex)
   {
      MessageBox.Show ( ex.Message, "HttpPost: Response error", 
         MessageBoxButtons.OK, MessageBoxIcon.Error );
   }
   return null;
} // end HttpPost 


...

In the web application access Request.Form to read the parameters:
C#
NameValueCollection nvc = Request.Form;
var p = nvc["Your parameter name"]


Regards
 
Share this answer
 
Comments
Prasanta_Prince 26-Apr-11 3:02am    
Good post.
Sandeep Mewara 26-Apr-11 5:03am    
my 5!
Sergey Alexandrovich Kryukov 26-Apr-11 13:12pm    
Looks correct, my 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900