I am attempting to host an application on Azure. Everything is going well except for when I attempt to run the program. Part of the code sends a HTTP GET Request to localhost to retrieve data from other files. However, it results in this error page:
Server Error in '/' Application.
An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:1443
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:1443
Source Error:
Line 9: <div id="menu">
Line 10: <%=
Line 11: ServerSideWebReader.WebReader.fetch("http://localhost:1443/Ajax/Widgets/Navigation/Navigation.aspx?id=Welcome to <Removed>", new string[0], new string[0]) %>
Line 12: </div>
Line 13:
Source File: c:\home\site\wwwroot\Default.aspx Line: 11
Stack Trace:
[SocketException (0x271d): An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:1443]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +194
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +591
[WebException: Unable to connect to the remote server]
System.Net.WebClient.UploadValues(Uri address, String method, NameValueCollection data) +508
System.Net.WebClient.UploadValues(String address, String method, NameValueCollection data) +38
ServerSideWebReader.WebReader.fetch(String url, String[] paramNames, String[] paramValues) in C:\GuerillaDevCo\ServerSideWebReader\WebReader.cs:18
ASP.default_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\home\site\wwwroot\Default.aspx:11
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +270
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +14
System.Web.UI.Page.Render(HtmlTextWriter writer) +30
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +67
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +101
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +27
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1342
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4330.0
We have been able to successfully run this program on Windows Server 2012 previously. It is now running on Azure. I've read in the Azure documentation that any requests to localhost must have a listening socket for that port. However, it states that the specified port must be greater than 1024. If I change the port for the HTTP Request to something besides 80 (HTTP) or 433 (HTTPS) so that I can conform with the constraint, will the HTTP Request still be able to receive a standard response?
Additionally, I would like to know how to create a listening socket using C# or some other tool that works with Azure. This project is currently using ASP.NET V4.8.
TL;DR I want to find a way to successfully allow HTTP Requests to localhost in my application on Azure. I have 2 questions/concerns relating to that that I'd like help with.
- Confirmation/Information regarding using a port higher than 1042 for HTTP request to local host.
- Information on how to create a listening socket whether with C# or some other appraoch.