I have been trying to figure out why this post method isn't going through. I've been using Fiddler, and have been working on this for hours now. If someone could help that would be great.
private string getemail(string user, string pass)
{
var cookies = new CookieContainer();
var getRequest = (HttpWebRequest)WebRequest.Create("http://account.mojang.com/migrate");
cookies = (getRequest as HttpWebRequest).CookieContainer;
string[] tok = ReadResponse(getRequest).Split(new string[] { "name=\"authenticityToken\" value=\"" }, StringSplitOptions.None);
string[] toke = tok[1].Split('"');
string token = toke[0];
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://account.mojang.com/migrate/check");
request.CookieContainer = cookies;
request.Method = "POST";
request.Headers.Add("Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3");
request.Headers.Add("Accept-Encoding: gzip,deflate,sdch");
request.Headers.Add("Accept-Language: en-US,en;q=0.8");
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31";
request.ContentType = "text/plain";
using (var requestStream = request.GetRequestStream())
{
using (var writer = new StreamWriter(requestStream))
{
writer.Write("authenticityToken=" + token + "&mcusername=" + user + "&password=" + pass);
}
}
using (var responseStream = request.GetResponse().GetResponseStream())
{
using (var reader = new StreamReader(responseStream))
{
var result = reader.ReadToEnd();
return result;
}
}
}
Close your StreamWriter after writing content into request stream.
using (var writer = new StreamWriter(requestStream))
{
writer.Write("authenticityToken=" + token + "&mcusername=" + user + "&password=" + pass);
writer.Close();
}
Related
I am working on calling asmx webservice method without adding service reference as asmx doesn't provide wsdl. I can access asmx service from fiddler as well as from postman. It works fine. However when I try to call it from my C# code it throws 403 forbidden exception.
Below is my c# code.
internal class Class3
{
string _soapEnvelope =
#"<soap:Envelope
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Body></soap:Body></soap:Envelope>";
private string CreateSoapEnvelope()
{
Dictionary<string, string> Params = new Dictionary<string, string>();
Params.Add("aId", "11"); // Add parameterName & Value to dictionary
Params.Add("cId", "22");
Params.Add("lId", "20");
string MethodCall = "<" + "GetSettings" + #" xmlns=""http://tempuri.org/"">";
string StrParameters = string.Empty;
foreach (var param in Params)
{
StrParameters += string.Format("<{0}>{1}</{0}>", param.Key, param.Value);
}
MethodCall = MethodCall + StrParameters + "</" + "GetSettings" + ">";
StringBuilder sb = new StringBuilder(_soapEnvelope);
sb.Insert(sb.ToString().IndexOf("</soap:Body>"), MethodCall);
return sb.ToString();
}
private HttpWebRequest CreateWebRequest()
{
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("sample.asmx");
webRequest.Headers.Add("SOAPAction", "\"http://tempuri.org/" + "GetSettings" + "\"");
webRequest.Headers.Add("To", "sample.asmx");
webRequest.Credentials = CredentialCache.DefaultCredentials;
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9";
webRequest.Host = "sample.com";
webRequest.Headers.Set(HttpRequestHeader.CacheControl, "max-age=0");
webRequest.Headers.Add("Upgrade-Insecure-Requests: 1");
webRequest.Headers.Add("Origin", "null");
webRequest.Headers.Add("Accept-Encoding", "gzip, deflate");
webRequest.Headers.Add("Accept-Language", "en-US,en;q=0.9,zh-CN;q=0.8,zh-TW;q=0.7,zh;q=0.6");
webRequest.Method = "POST";
return webRequest;
}
public string InvokeService()
{
try
{
WebResponse response = null;
string strResponse = "";
//Create the request
HttpWebRequest req = this.CreateWebRequest();
//write the soap envelope to request stream
using (Stream stm = req.GetRequestStream())
{
using (StreamWriter stmw = new StreamWriter(stm))
{
stmw.Write(this.CreateSoapEnvelope());
}
}
//get the response from the web service
response = req.GetResponse();
Stream str = response.GetResponseStream();
StreamReader sr = new StreamReader(str);
strResponse = sr.ReadToEnd();
return HttpUtility.HtmlDecode(strResponse);
}
catch (Exception ex)
{
return "";
}
}
}
internal class Program
{
static void Main(string[] args)
{
new Class3().InvokeService();
}
}
Tried adding below headers as well but it doesnt make any difference.
webRequest.ContentLength = 600000;
webRequest.ProtocolVersion = HttpVersion.Version11;
webRequest.KeepAlive = false;
webRequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36";
I am using VS2022 - Console Application with .Net Framework 4.6.2
Can somebody please help me understand what am I doing wrong here.
after lot of research I got to know that the way I am passing parameters were incorrect. Below is the simple and correct version of doing same. Its working now
string remoteUrl = "service.asmx";
string poststring = "aId=11&cId=22&lId=20";
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(remoteUrl);
httpRequest.Host = "host.com";
httpRequest.Method = "POST";
httpRequest.ContentType = "application/x-www-form-urlencoded";
httpRequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.5195.127 Safari/537.36";
// Convert the post string to a byte array
byte[] bytedata = System.Text.Encoding.UTF8.GetBytes(poststring);
httpRequest.ContentLength = bytedata.Length;
// Create the stream
Stream requestStream = httpRequest.GetRequestStream();
requestStream.Write(bytedata, 0, bytedata.Length);
requestStream.Close();
// Get the response from remote server
HttpWebResponse httpWebResponse = (HttpWebResponse)httpRequest.GetResponse();
Stream responseStream = httpWebResponse.GetResponseStream();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
using (StreamReader reader = new StreamReader(responseStream, System.Text.Encoding.UTF8))
{
string line;
while ((line = reader.ReadLine()) != null)
{
sb.Append(line);
}
}
string data = sb.ToString();
I'm trying to make a json POST to the Mojang authentification server using a HttpWebRequest in C#.
I checked the headers with a Chrome addon and added them.
Below is my code, but I keep getting a 403 forbidden.
I got it working with a TcpClient but I need to do it with a HttpWebRequest as it accepts proxies.
Does someone now how to fix this?
public void test(string username, string password) {
try {
ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(ValidateRemoteCertificate);
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
string json = "{\"agent\":{\"name\":\"Minecraft\",\"version\":1},\"username\":\"" + username + "\",\"password\":\"" + password + "\",\"clientToken\":\"6c9d237d-8fbf-44ef-b46b-0b8a854bf391\"}";
var httpWebRequest = (HttpWebRequest) WebRequest.Create("https://authserver.mojang.com/authenticate");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.ContentLength = json.Length;
httpWebRequest.Host = "authserver.mojang.com";
httpWebRequest.Credentials = CredentialCache.DefaultCredentials;
httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36";
httpWebRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
httpWebRequest.Referer = "https://authserver.mojang.com/";
httpWebRequest.Headers.Add("Accept-Language", "de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4");
httpWebRequest.Headers.Add("Accept-Encoding", "gzip, deflate, sdch, br");
using(var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) {
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
var httpResponse = (HttpWebResponse) httpWebRequest.GetResponse();
using(var streamReader = new StreamReader(httpResponse.GetResponseStream())) {
var result = streamReader.ReadToEnd();
MessageBox.Show(result);
streamReader.Close();
}
} catch (Exception error) {
MessageBox.Show(error.ToString());
}
}
i am integrating rightmove real time data feed (rtdf) in my property site for listing my properties on rightmove website. i am using asp.net web api to post data on rightmove listing.
they have provide me with these SSL Files [.p12,.pem,.jks]. i have imported .p12 certificate in my local machine personal store and sending it in my http request
to rightmove test api link provide by rightmove.
i am getting the following error from server.
The remote server returned an error: 403 forbidden.
i checked my certificate loaded successfully in the request, below is my code
public static string PostData(string data, string url)
{
String result = "";
try
{
byte[] bytebuffer = Encoding.UTF8.GetBytes(data);
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.Method = "POST";
objRequest.ContentLength = bytebuffer.Length;
objRequest.ContentType = "application/json";
objRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0";
objRequest.PreAuthenticate = true;
objRequest.Accept = "application/json";
objRequest.ClientCertificates.Add(CertificateHelper.GetRightmoveApiX509Certificate());
using (Stream stream = objRequest.GetRequestStream())
{
stream.Write(bytebuffer, 0, bytebuffer.Length);
stream.Close();
}
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
using (StreamReader streamReader = new StreamReader(objResponse.GetResponseStream()))
{
result = streamReader.ReadToEnd();
// Close and clean up the StreamReader
streamReader.Close();
}
}
catch (Exception e)
{
result = "Exception: " + e.Message;
}
return result;
}
help me to get rid from 403 forbidden error.
Use the following.
I have tested it and it's working fine in my case.
// Grab Certificate
X509Certificate2 cert2 = new X509Certificate2(
AppDomain.CurrentDomain.BaseDirectory + "CertificateName.p12",
CertificatePasswordHere,
X509KeyStorageFlags.MachineKeySet);
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://adfapi.adftest.rightmove.com/v1/property/sendpropertydetails");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.ClientCertificates.Clear();
httpWebRequest.ClientCertificates.Add(cert2);
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
streamWriter.Write(data);
streamWriter.Flush();
streamWriter.Close();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
}
I'm trying to the html information on a certain a website so I can parse out the info for our database. The problem is that the second & third responseFromServer info comes back the same. However, when I follow the links on inside a real web browser, I get the right information (correct page).
I'm thinking that each WebRequest is basically opening a 'new' instance of the web and what I want it to do is use the same instance.
Is there a way to specify (using a WebClient?) so that each request is contained in the 'same browser' (for lack of a better term)
static void CountyInfo(string Address)
{
WebClient webClient = new WebClient();
webClient.Headers.Add("Cache-Control: private");
webClient.Headers.Add("Content-Type: text/html; charset=utf-8");
webClient.Headers.Add("Server: Microsoft-IIS/6.0");
webClient.Headers.Add("X-AspNet-Version: 4.0.30319");
webClient.Headers.Add("X-Powered-By: ASP.NET");
webClient.Headers.Add("X-UA-Compatible: IE=8, IE=9, IE=10, IE=11");
Address = Address.Replace(" ", "+");
string url1 = "http://mcassessor.maricopa.gov/?s=" + Address;
WebRequest request1 = WebRequest.Create(url1);
WebResponse response1 = request1.GetResponse();
//Stream dataStream1 = response1.GetResponseStream();
Stream dataStream1 = webClient.OpenRead(url1);
StreamReader reader1 = new StreamReader(dataStream1);
string responseFromServer1 = reader1.ReadToEnd();
string ParcelNum = getBetween(responseFromServer1, "http://treasurer.maricopa.gov/parcels/default.asp?Parcel=", "target=");
ParcelNum = new String(ParcelNum.Where(Char.IsDigit).ToArray());
//reader1.Close();
//response1.Close();
//NEW GET request
string url2 = "http://treasurer.maricopa.gov/parcels/default.asp?Parcel=" + ParcelNum;
WebRequest request2 = WebRequest.Create(url2);
WebResponse response2 = request2.GetResponse();
//Stream dataStream2 = response2.GetResponseStream();
Stream dataStream2 = webClient.OpenRead(url2);
StreamReader reader2 = new StreamReader(dataStream2);
string responseFromServer2 = reader2.ReadToEnd();
//reader2.Close();
//response2.Close();
//NEW GET request
string url3 = "http://treasurer.maricopa.gov/Parcel/" + "TaxDetails.aspx?taxyear=2013";
WebRequest request3 = WebRequest.Create(url3);
WebResponse response3 = request3.GetResponse();
//Stream dataStream3 = response3.GetResponseStream();
Stream dataStream3 = webClient.OpenRead(url3);
StreamReader reader3 = new StreamReader(dataStream3);
string responseFromServer3 = reader3.ReadToEnd();
reader3.Close();
response3.Close();
}
EDIT: just saw this. request1 gives me the correct page (the query results page) but request 2 and 3 return me back to the "Home Page" of the website. Even though i am passing in url2 and url3 into the requests2 & 3 respectively.
You need to manage the cookies. Get the cookies served by the web server and pass them back on the next request.
Sorry about the long code post, but this is how i got it working. Let me know if you can condense it any.
static public CookieContainer cookieJar;
static void Main(string[] args)
{
string ControlNumber = "######";
GetOrderInfo newOrder = new GetOrderInfo(ControlNumber);
obtainCookies();
MARICOPAcounty(newOrder.OrderAddress);
}
static void obtainCookies()
{
string postData = "http://mcassessor.maricopa.gov/";
CookieContainer tempCookies = new CookieContainer();
UTF8Encoding encoding = new UTF8Encoding();
byte[] byteData = encoding.GetBytes(postData);
HttpWebRequest postReq = (HttpWebRequest)WebRequest.Create("http://mcassessor.maricopa.gov/");
postReq.Method = "POST";
postReq.KeepAlive = true;
Cookie chocoChip = new Cookie("_ga", "GA1.2.1813386723.1386802842") { Domain = "http://mcassessor.maricopa.gov/" };
postReq.CookieContainer = new CookieContainer();
postReq.CookieContainer.Add(chocoChip);
postReq.ContentType = "text/html; charset=utf-8";
postReq.Referer = "http://mcassessor.maricopa.gov/";
postReq.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; MAM3; rv:11.0) like Gecko";
postReq.ContentLength = byteData.Length;
Stream postReqStream = postReq.GetRequestStream();
postReqStream.Write(byteData, 0, byteData.Length);
postReqStream.Close();
HttpWebResponse postResponse;
postResponse = (HttpWebResponse)postReq.GetResponse();
postResponse.Cookies.Add(chocoChip);
StreamReader postReqReader = new StreamReader(postResponse.GetResponseStream());
tempCookies.Add(chocoChip);
cookieJar = tempCookies;
string soureCode = postReqReader.ReadToEnd();
if (postReq != null)
{
Console.WriteLine("\r\n\r\n postResponse COOKIES");
Console.WriteLine(postResponse.Cookies[0]);
Console.WriteLine("\r\n\r\n postReq Headers");
Console.WriteLine(postReq.Headers.ToString());
Console.WriteLine("\r\n\r\n postResponse Headers");
Console.Write("\t" + postResponse.Headers);
}
}
public static string MARICOPAcounty(string Address)
{
//-------------------------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------------------------------------//
Address = Address.Replace(" ", "+");
string url1 = "http://mcassessor.maricopa.gov/?s=" + Address;
HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create(url1);
request1.CookieContainer = cookieJar;
request1.Method = "GET";
request1.Accept = "text/html, application/xhtml+xml, */*";
request1.Headers.Add("Accept-Language: en-US");
request1.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; MAM3; rv:11.0) like Gecko";
request1.Headers.Add("Accept-Enconding: gzip, deflate");
HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse();
StreamReader sr1 = new StreamReader(response1.GetResponseStream());
string sourceCode1 = sr1.ReadToEnd();
string ParcelNum = getBetween(sourceCode1, "http://treasurer.maricopa.gov/parcels/default.asp?Parcel=", "target=");
ParcelNum = new String(ParcelNum.Where(Char.IsDigit).ToArray());
if (response1 != null)
{
Console.WriteLine("\r\n\r\n request1 Headers");
Console.WriteLine(request1.Headers.ToString());
Console.WriteLine("\r\n\r\nresponse1 Headers");
Console.Write("\t" + response1.Headers);
}
sr1.Close();
response1.Close();
//-------------------------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------------------------------------//
//NEW GET request
string url2 = "http://treasurer.maricopa.gov/parcels/default.asp?Parcel=50423370"; //+ ParcelNum;
HttpWebRequest request2 = (HttpWebRequest)WebRequest.Create(url2);
request2.CookieContainer = cookieJar;
request2.Method = "GET";
request2.Accept = "text/html, application/xhtml+xml, */*";
request2.Headers.Add("Accept-Language: en-US");
request2.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; MAM3; rv:11.0) like Gecko";
request2.Headers.Add("Accept-Encoding: gzip, deflate");
request2.Referer = url1;
HttpWebResponse response2 = (HttpWebResponse)request2.GetResponse();
StreamReader sr2 = new StreamReader(response2.GetResponseStream());
string sourceCode2 = sr2.ReadToEnd();
if (response2 != null)
{
Console.WriteLine("\r\n\r\nrrequest2 Headers");
Console.WriteLine(request2.Headers);
Console.WriteLine(request2.CookieContainer);
Console.WriteLine("\r\n\r\nresponse2 Headers");
Console.Write("\t" + response2.Headers);
}
sr2.Close();
response2.Close();
//-------------------------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------------------------------------------------------------------------------------//
//new GET request
string url3 = "http://treasurer.maricopa.gov/Parcel/TaxDetails.aspx?taxyear=2013";
HttpWebRequest request3 = (HttpWebRequest)WebRequest.Create(url3);
request3.CookieContainer = cookieJar;
request3.Method = "GET";
request3.Accept = "text/html, application/xhtml+xml, */*";
request3.Headers.Add("Accept-Language: en-US");
request3.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; MAM3; rv:11.0) like Gecko";
request3.Headers.Add("Accept-Encoding: gzip, deflate");
request3.Referer = url2;
HttpWebResponse response3 = (HttpWebResponse)request3.GetResponse();
StreamReader sr3 = new StreamReader(response3.GetResponseStream());
string sourceCode3 = sr3.ReadToEnd();
if (response3 != null)
{
Console.WriteLine("\r\n\r\nrrequest3 Headers");
Console.WriteLine(request3.Headers);
Console.WriteLine("\r\n\r\nresponse3 Headers");
Console.Write("\t" + response3.Headers);
}
sr3.Close();
response3.Close();
return sourceCode3;
}
I am encountering a problem getting the access_token in client application using oauth.
The returned response has empty body though in API I can see the response is not empty.
tokenresponse = {
"access_token":"[ACCESSTOKENVALUE]",
"token_type":"bearer",
"expires_in":"1200",
"refresh_token":"[REFRESHTOKENVALUE]",
"scope":"[SCOPEVALUE]"
}
The method from API that returns the token http://api.sample.com/OAuth/Token:
public ActionResult Token()
{
OutgoingWebResponse response =
this.AuthorizationServer.HandleTokenRequest(this.Request);
string tokenresponse = string.Format("Token({0})", response!=null?response.Body:""));
return response.AsActionResult();
}
The client method that requests the token is:
public string GetAuthorizationToken(string code)
{
string Url = ServerPath + "OAuth/Token";
string redirect_uri_encode = UrlEncode(ClientPath);
string param = string.Format("code={0}&client_id={1}&client_secret={2}&redirect_uri={3}&grant_type=authorization_code",code, ClientId, ClientSecret, redirect_uri_encode);
HttpWebRequest request = HttpWebRequest.Create(Url) as HttpWebRequest;
string result = null;
request.Method = "POST";
request.KeepAlive = true;
request.ContentType = "application/x-www-form-urlencoded";
request.Timeout = 10000;
request.Headers.Remove(HttpRequestHeader.Cookie);
var bs = Encoding.UTF8.GetBytes(param);
using (Stream reqStream = request.GetRequestStream())
{
reqStream.Write(bs, 0, bs.Length);
}
using (WebResponse response = request.GetResponse())
{
var sr = new StreamReader(response.GetResponseStream());
result = sr.ReadToEnd();
sr.Close();
}
if (!string.IsNullOrEmpty(result))
{
TokenData tokendata = JsonConvert.DeserializeObject<TokenData>(result);
return UpdateAuthorizotionFromToken(tokendata);
}
return null;
}
The result variable is empty.
Please let me know if you have any idea what could cause this. Initially I assumed is because of the cookies so I tried to remove them from request.
Thanks in advance.
Dear just create webclient using following code and you will get json info in tokeninfo.I used it and simply its working perfect.
WebClient client = new WebClient();
string postData = "client_id=" + ""
+ "&client_secret=" + ""
+ "&grant_type=password&username=" + "" //your username
+ "&password=" + "";//your password :)
string soundCloudTokenRes = "https://api.soundcloud.com/oauth2/token";
string tokenInfo = client.UploadString(soundCloudTokenRes, postData);
You can then use substring that contains only token from tokeninfo.
To upload tracks on sound cloud.
private void TestSoundCloudupload()
{
System.Net.ServicePointManager.Expect100Continue = false;
var request = WebRequest.Create("https://api.soundcloud.com/tracks") as HttpWebRequest;
//some default headers
request.Accept = "*/*";
request.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.3");
request.Headers.Add("Accept-Encoding", "gzip,deflate,sdch");
request.Headers.Add("Accept-Language", "en-US,en;q=0.8,ru;q=0.6");
//file array
var files = new UploadFile[] { new UploadFile(Server.MapPath("Downloads//0.mp3"), "track[asset_data]", "application/octet-stream") };
//other form data
var form = new NameValueCollection();
form.Add("track[title]", "Some title");
form.Add("track[sharing]", "public");
form.Add("oauth_token", "");
form.Add("format", "json");
form.Add("Filename", "0.mp3");
form.Add("Upload", "Submit Query");
try
{
using (var response = HttpUploadHelper.Upload(request, files, form))
{
using (var reader = new StreamReader(response.GetResponseStream()))
{
Response.Write(reader.ReadToEnd());
}
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}