Home All Groups Group Topic Archive Search About

HttpWebRequest Fails When Run as Non-Admin Account On Vista

Author
27 Feb 2009 1:08 AM
hpux9@nospam.nospam
When I run the code below on Vista 32 (or 64) with a non admin account it
fails.  On Vista, as Adminit works with no problems.  On XP it works with no
problem as admin or non-admin.

Please Help!!!

Error, code to follow:
=============================
F:\>webtest
Message: Unable to read data from the transport connection: A non-blocking
socket operation could not be completed immediately.
StackTrace:    at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset,
Int32 size)
   at System.IO.StreamReader.ReadBuffer()
   at System.IO.StreamReader.ReadToEnd()
   at WebTest.WebTest.Main(String[] args)
Inner Exception: System.Net.Sockets.SocketException: A non-blocking socket
operation could not be completed immediately
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32
size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset,
Int32 size)
Done

Code
=========================
using System;
using System.Net;
using System.IO;

namespace WebTest
{
    class WebTest
    {
        static void Main(string[] args)
        {
            try{
                HttpWebRequest webreq =
(HttpWebRequest)WebRequest.Create("http://www.merriam-webster.com/dictionary/automobile");
                WebResponse webresp = webreq.GetResponse();
                Stream s = webresp.GetResponseStream();
                StreamReader sr = new StreamReader(s);
                string page = sr.ReadToEnd();
                webresp.Close();
                Console.WriteLine("no error");
            }
            catch(Exception e)
            {
                string err = "Message: " + e.Message + Environment.NewLine;
                err += "StackTrace: " + e.StackTrace;
                err += "Inner Exception: " + e.InnerException;

                Console.WriteLine(err);
            }
            Console.WriteLine("Done");
        }
    }
}

Author
2 Mar 2009 8:13 PM
James Matthews
Try allowing a blocking connection...

--

http://www.astorandblack.com/
<hpux9@nospam.nospam> wrote in message
Show quoteHide quote
news:CB1476D5-B3F4-422E-8B44-ADE3D767B817@microsoft.com...
> When I run the code below on Vista 32 (or 64) with a non admin account it
> fails.  On Vista, as Adminit works with no problems.  On XP it works with
> no
> problem as admin or non-admin.
>
> Please Help!!!
>
> Error, code to follow:
> =============================
> F:\>webtest
> Message: Unable to read data from the transport connection: A non-blocking
> socket operation could not be completed immediately.
> StackTrace:    at System.Net.ConnectStream.Read(Byte[] buffer, Int32
> offset,
> Int32 size)
>   at System.IO.StreamReader.ReadBuffer()
>   at System.IO.StreamReader.ReadToEnd()
>   at WebTest.WebTest.Main(String[] args)
> Inner Exception: System.Net.Sockets.SocketException: A non-blocking socket
> operation could not be completed immediately
>   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32
> size, SocketFlags socketFlags)
>   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset,
> Int32 size)
> Done
>
> Code
> =========================
> using System;
> using System.Net;
> using System.IO;
>
> namespace WebTest
> {
>    class WebTest
>    {
>        static void Main(string[] args)
>        {
>            try{
>                HttpWebRequest webreq =
> (HttpWebRequest)WebRequest.Create("http://www.merriam-webster.com/dictionary/automobile");
>                WebResponse webresp = webreq.GetResponse();
>                Stream s = webresp.GetResponseStream();
>                StreamReader sr = new StreamReader(s);
>                string page = sr.ReadToEnd();
>                webresp.Close();
>                Console.WriteLine("no error");
>            }
>            catch(Exception e)
>            {
>                string err = "Message: " + e.Message + Environment.NewLine;
>                err += "StackTrace: " + e.StackTrace;
>                err += "Inner Exception: " + e.InnerException;
>
>                Console.WriteLine(err);
>            }
>            Console.WriteLine("Done");
>        }
>    }
> }
>
>