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’ve also posted this question to: http://social.msdn.microsoft.com/Forums/en-US/windowsazuredevelopment/thread/622f0dbc-bbfd-4d3e-b344-148a79ddeedc
If I change the URL to the RSS feed that I am reading from an Https to an Http link, all works well. Luckily picasaweb just redirects to https on there side so all works well.
I’d live to know how to resolve this to allow the code to actually use SSL, but in the mean time, this has been resolved.