none
HttpWebRequest from Windows Azure Web Site

    Question

  • I have just today released my first web site on Windows Azure Web Sites. From this web site, I am trying to get content from an external RSS feed (https://picasaweb.google.com/) using an HTTPWebRequest.

    I execute the following method from an MVC controller in and then fill a model with the resulting RSS XML:

        private static string HttpGet(String url)
        {
            HttpWebRequest req = WebRequest.Create(url) as HttpWebRequest;
            String result = null;
            using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(resp.GetResponseStream());
                result = reader.ReadToEnd();
            }
            return result;
        }
    

    This works fine from my local machine when I test this, but once the site is uploaded to Windows Azure Web sites, clicking on the page results:  

    Sorry, an error occurred while processing your request.

    My guess is that I need to open a firewall port to allow the web server to make port 443 requests from inside the data centre, but I can't find where or how to do this.

    Any ideas would be much appreciated.

    Update:
    I think my original assumption was correct - I don't seem to be able to make an SSL request from inside Azure. Here is the stacktrace below:

    [WebException: The request was aborted: Could not create SSL/TLS secure channel.]
       System.Net.HttpWebRequest.GetResponse() +6115603
       Alien.Models.PicassaWebReader.HttpGet(String url) +61
       Alien.Models.PicassaWebReader.GetPicassaWebFeed() +17
       Alien.Controllers.PhotosController.Index() +14
       lambda_method(Closure , ControllerBase , Object[] ) +62
       System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
       System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
       System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
       System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
       System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
       System.Web.Mvc.Controller.ExecuteCore() +116
       System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
       System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
       System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
       System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
       System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
       System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
       System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
       System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
       System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8969201
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

    I have also posted this question at: http://stackoverflow.com/questions/11369128/httpwebrequest-from-windows-azure-web-site


    Gineer

    Monday, July 09, 2012 9:01 AM

All replies

  • Hi Gineer,

    To reproduce the issue which you are facing, i have created a sample azure application. In default.aspx page i have added a textbox which will show the result of HttpResponse-

    In th page load event i have called the HttpGet method (as specified by you) & set the result in textbox-

    string strURL = "https://picasaweb.google.com/";
    TextBox1.Text= HttpGet(strURL);

    Please got below result when i executed the page in windows azure environment.


    Let me know you want to achive something similar that i did or else.

    Please create a sample application (as i did) & check will you be able to get results or not.

    Thanks


    dharampal sikhwal

    Monday, July 09, 2012 6:36 PM
  • Hi Dharampal,

    The method listing in the original post is the actual peice of code I am trying to use. According to the stack trace, it failes at the point where it wants to get a response. Last night I changed the link from https to http. I changed nothing else and re-uploaded my site and all owrked well. As stated by the error, it was not able to create an SSL/STL secure channel.

    I still think this has something to do with a firewall rule or something I have enable on my Azure web site.

    Thanks anyway and I'd love to hear if you have any new ideas.

    Gineer


    Gineer

    Tuesday, July 10, 2012 9:46 AM
  • Have you solved the problem? Try to solve it on your own. If you have web site related questions, you can post on http://social.msdn.microsoft.com/Forums/en-US/windowsazurewebsitespreview/threads

    This account is used to congratulate those who solve their own problems. Since it is your issue, try to figure it out on your own. Others can only help, not do the work for you.

    Thursday, July 19, 2012 7:01 AM