Calling URL from code behind C# in asp.net

Feb 19 2019 1:09 AM
HI guys ,
 
"http://www.google.com/transliterate/indic?tlqt=1&langpair=en|hi&text=" + HttpUtility.UrlEncode("India") + "&from=en&to=hi;
 
I have some issue when i am calling this url from code behind .
 
The remote server returned an error: (404) Not Found this error i'm getting.
 
but if i directly put this URL then it is working file is also downloading.
 
Here is my code
 
uri = "http://www.google.com/transliterate/indic?tlqt=1&langpair=en|hi&text=" + HttpUtility.UrlEncode("India") + "&from=en&to=hi;
HttpWebRequest translationWebRequest = (HttpWebRequest)WebRequest.Create(uri);
WebResponse response = null;
response = translationWebRequest.GetResponse();// in this line error is coming
Stream stream = response.GetResponseStream();
Encoding encode = Encoding.GetEncoding("utf-8");
StreamReader translatedStream = new StreamReader(stream, encode);
 
Can any one help me ... how to solve this error!

Answers (3)