Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have to call third party .ashx page which returns a string.How can i read the string returned by .ashx file in my .aspx page?

here is my request format:
XML
http:// www.remoteServerName.in /recharge.ashx?uid=<user_id>&pwd=<password>
&mobileno=<mobile_number>&amt=<recharge_amount>&transid=<transacti
on_id>


After processing the above request it will return the response, How to read that?

Thanks in advance....
Posted

hi
you can do i thing, see below i explained...

WebRequest request =(HttpWebRequest) WebRequest.Create("URL")

WebResponse response = request.GetResponse ();

Stream dataStream = response.GetResponseStream ();

StreamReader reader = new StreamReader (dataStream);

string responseFromServer = reader.ReadToEnd ();

reader.Close ();
response.Close ();



here, responseFromServer will contain the output received from requested url.


If it is useful please vote for this answer.

Thanks
 
Share this answer
 
You need to create webrequest object
// Create a request for the URL.
C#
WebRequest request = WebRequest.Create ("http:// www.remoteServerName.in /recharge.ashx?uid=<user_id>&pwd=<password>
&mobileno=<mobile_number>&amt=<recharge_amount>&transid=<transacti");></recharge_amount></mobile_number></password></user_id>

Get response by calling GetResponse () method
C#
var response = request.GetResponse ();
 
Share this answer
 
Comments
Mahesh1220 12-Aug-13 3:34am    
Thank you both.....

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