HttpWebRequest doesn't work while it works in CLR RRS feed

  • Question

  • User-842092983 posted

    I have a simple code to call a web page, like below

    function getcontent(string url){
       Uri uri = new Uri(url);      
       HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);       
      HttpWebResponse response = (HttpWebResponse)request.GetResponse();      
     Stream responseStream = response.GetResponseStream();      
      StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8);       
      return readStream.ReadToEnd();

    the exact function is in a CLR and deployed to my SQL server.

    now I have a rss url , when I call the function to get the content of the url, it works fine in the SQL when calls the CLR.

    But when I call the function in a user control in my web app, I always get exception "Unable to connect to the remote server", I searched and found someone mentioned about keep-alive issue etc. but I haven't figured out a way to solve the problem.

    Any idea? thanks!

    Thursday, July 11, 2013 2:37 PM

All replies

  • User-842092983 posted

    anyone can help?


    Monday, July 15, 2013 12:57 PM
  • User-842092983 posted

    Seems the link is not about the same issue, I did a sync call, the link you provided is about async call. I don't see same problem with my sync call code

    Tuesday, July 16, 2013 12:35 PM
  • User260886948 posted


    Please try to enable tracing for ASMX, then it will help you to find the case.

    The following is about using the following sample configuration to enable tracing for ASMX:

        <trace autoflush="true" />
            <source name="System.Web.Services.Asmx">
                    <add name="AsmxTraceFile" type="System.Diagnostics.TextWriterTraceListener" initializeData="local.log" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId" />
            <add name="System.Web.Services.Asmx" value="Verbose"  />

    For more information, please try to refer to:

    #Enabling Tracing in ASP.NET Web Services:
    http://msdn.microsoft.com/en-us/library/vstudio/bb885203(v=vs.100).aspx .

    Hope it can help you.

    Best Regards,
    Amy Peng


    Thursday, July 18, 2013 2:54 AM
  • User-842092983 posted

    I am lost, what asmx? are you talking about the server side I tried to connect with the webrequest? it is not my service, so I cannot trace on that side.

    Thursday, July 18, 2013 12:50 PM