I developed one MVC web application which have Web APIs and hosted in Amazon Instance and one windows application for calling those APIs for getting response from that server.

Both Web and Windows applications are developed in asp.net framework 4.5 using c# language.

Windows application is installed in more than 200 client's system which are highly secure servers it selves with all Inbound ports blocked in Firewall.

I am using HttpWebRequest with BindIPEndPoint for calling Web APIs using configured TCP port range [default 7777-7786].

API calls working fine from Windows Application if there are Allow Inbound and Outbound firewall Rules.

But the problem is clients are not allowing me any Inbound Firewall rules, they only allowing Outbound Firewall rules for those port range And Windows application is not working with blocked inbound rules for those port range.

Is it must I need to open Inbound Rule in Firewall for those port range for calling/getting request/response to/from APIs ? If no need of Inbound Firewall rule then please explain Why ?

Below is the API call which use one static TCP port in my Windows Application :

    string address = RevWatchURL;
    address = address + "api/GetRevGuardLatestPatch";
    HttpWebRequest httpWebRequest = WebRequest.Create(address) as HttpWebRequest;
    httpWebRequest.ContentType = "text/json";
    httpWebRequest.Method = "POST";
    httpWebRequest.Timeout = 300000;

    httpWebRequest.ServicePoint.BindIPEndPointDelegate = 
                new BindIPEndPoint(CommonValues.BindIPEndPointCallbackRGPatch);

    string enRevGuardUniqueId = 
                Encryption.EncryptionTechnique(Convert.ToString(UniqueId), null, null);

    using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
        string json = "{\"UniqueId\":\"" + enRevGuardUniqueId + "\"}";


        var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
        using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            returnVal = streamReader.ReadToEnd();
    catch (WebException ex)

    Obj = JsonConvert.DeserializeObject<CommonValues.RevGuardPatchClass>(returnVal);
catch (Exception ex)
    MessageBox.Show("Error", "API", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

BindIPEndPoint Method:

public static IPEndPoint BindIPEndPointCallbackRGPatch(ServicePoint servicePoint, 
                                            IPEndPoint remoteEndPoint, int retryCount)
    return new IPEndPoint(IPAddress.Any, 7777);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.