unable to run the given sample code

  • 986 Views
  • Last Post 30 March 2013
sourabh posted this 29 March 2013

when i run your code for asp.net web application it is throwing an "Unable to connect remote server" exception please provide me the solution. I am running your sample code into v.s 2010 web application but it is throwing an error. the error into given below code segment:-

protected static void FillRequestWithContent(HttpWebRequest request, string contentPath)
    {
        try
        {
            using (BinaryReader reader = new BinaryReader(File.OpenRead(contentPath)))
            {
                request.ContentLength = reader.BaseStream.Length;
                using (Stream stream = request.GetRequestStream())
                {
                    byte[] buffer = new byte[reader.BaseStream.Length];
                    while (true)
                    {
                        int bytesRead = reader.Read(buffer, 0, buffer.Length);
                        if (bytesRead == 0)
                        {
                            break;
                        }
                        stream.Write(buffer, 0, bytesRead);
                    }
                }
            }
        }
        catch (Exception ex)
        {

        }
    }

Dmitry Me posted this 30 March 2013

Have you properly set up the application id and password?

Close