Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Help! ... Outbound Port Getting Shut Down

Reply
Thread Tools

Help! ... Outbound Port Getting Shut Down

 
 
TC
Guest
Posts: n/a
 
      06-08-2007
Hey All,

I have some classes that I recently built for a website which uses the
HttpWebRequest & HttpWebResponse objects from the System.Net namespace.
Basically, the classes rap submitted data up, connect to external websites
on external servers and post / remove the data from these other sites.

It works fine locally but when uploaded to the BCentral production server,
the outgoing requests get shutdown.

Apparently, for the System.Net name space, you cannot specify the port. The
outgoing port will be dynamic random. It will be the client port and not the
service port. The port range can be 1024 and above. It is by design and
there is no way you can specify the client port.

Now, as for BCentral, they do allow outbound connections but only on the
"default" ports such at 80 for http, etc. Every other non-essential port
is locked down and they don't open up other ports because of security
concerns.

Can someone please advise?

Thanks,

TC


 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      06-08-2007
HttpWebRequest will use any port (specify in url) you want but defaults
to port 80. not sure what your issue is. maybe some sample code.

-- bruce (sqlwork.com)

TC wrote:
> Hey All,
>
> I have some classes that I recently built for a website which uses the
> HttpWebRequest & HttpWebResponse objects from the System.Net namespace.
> Basically, the classes rap submitted data up, connect to external websites
> on external servers and post / remove the data from these other sites.
>
> It works fine locally but when uploaded to the BCentral production server,
> the outgoing requests get shutdown.
>
> Apparently, for the System.Net name space, you cannot specify the port. The
> outgoing port will be dynamic random. It will be the client port and not the
> service port. The port range can be 1024 and above. It is by design and
> there is no way you can specify the client port.
>
> Now, as for BCentral, they do allow outbound connections but only on the
> "default" ports such at 80 for http, etc. Every other non-essential port
> is locked down and they don't open up other ports because of security
> concerns.
>
> Can someone please advise?
>
> Thanks,
>
> TC
>
>

 
Reply With Quote
 
 
 
 
TC
Guest
Posts: n/a
 
      06-08-2007
Hey Bruce,

Thanks for the response.

Do you want me to post it inline or as an attachment in .zip file?

Would you prefer that I send the source to you personally?

I should also add that the code is for VS 2003

Thanks,

Todd


"bruce barker" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> HttpWebRequest will use any port (specify in url) you want but defaults to
> port 80. not sure what your issue is. maybe some sample code.
>
> -- bruce (sqlwork.com)
>
> TC wrote:
>> Hey All,
>>
>> I have some classes that I recently built for a website which uses the
>> HttpWebRequest & HttpWebResponse objects from the System.Net namespace.
>> Basically, the classes rap submitted data up, connect to external
>> websites on external servers and post / remove the data from these other
>> sites.
>>
>> It works fine locally but when uploaded to the BCentral production
>> server, the outgoing requests get shutdown.
>>
>> Apparently, for the System.Net name space, you cannot specify the port.
>> The outgoing port will be dynamic random. It will be the client port and
>> not the service port. The port range can be 1024 and above. It is by
>> design and there is no way you can specify the client port.
>>
>> Now, as for BCentral, they do allow outbound connections but only on the
>> "default" ports such at 80 for http, etc. Every other non-essential
>> port is locked down and they don't open up other ports because of
>> security concerns.
>>
>> Can someone please advise?
>>
>> Thanks,
>>
>> TC



 
Reply With Quote
 
TC
Guest
Posts: n/a
 
      06-08-2007
Hey Bruce,

I'm going to post some material inline herein. Let's just assume that all
constant strings, values, viewstate, etc. work.

I think if I paste in the material with the actual calls, it might mean
something to you.

Thanks,

TC



/// <summary>
/// Builds a WebRequest object based upon the parameters passed in
/// </summary>
/// <param name="uriURL">See documentation for HttpWebRequest
parameters</param>
/// <param name="cookieJar">See documentation for HttpWebRequest
parameters</param>
/// <param name="userAgent">See documentation for HttpWebRequest
parameters</param>
/// <param name="requestMethod">See documentation for HttpWebRequest
parameters</param>
/// <param name="timeOut">See documentation for HttpWebRequest
parameters</param>
/// <param name="contentType">See documentation for HttpWebRequest
parameters</param>
/// <param name="keepAlive">See documentation for HttpWebRequest
parameters</param>
/// <param name="allowAutoRedirect">See documentation for HttpWebRequest
parameters</param>
/// <returns></returns>
public static HttpWebRequest BuildHTTPWebRequest(string uriURL,
CookieContainer cookieJar, string userAgent,
string requestMethod, int timeOut,
string contentType, bool keepAlive,
bool allowAutoRedirect)
{
Uri UriRequest;
HttpWebRequest HttpWRequest;

UriRequest = new Uri(uriURL);
HttpWRequest = (HttpWebRequest)WebRequest.Create(UriRequest);
HttpWRequest.CookieContainer=cookieJar;
// Set the name of the user agent. This is the client name that is passed
to IIS
HttpWRequest.UserAgent = userAgent;
HttpWRequest.KeepAlive = keepAlive;
HttpWRequest.AllowAutoRedirect=allowAutoRedirect;
HttpWRequest.Timeout = timeOut;
HttpWRequest.Method = requestMethod;
HttpWRequest.ContentType = contentType;
// We don't want caching to take place so we need
// to set the pragma header to say we don't want caching
HttpWRequest.Headers.Set(WebPost.Pragma,WebPost.No Cache);
// The server may not understand this new header; disable it
System.Net.ServicePointManager.Expect100Continue=f alse;

return HttpWRequest;
}

/// <summary>
/// Logs into the perfectsplitmd.com website
/// </summary>
public static void PerfectSplitLogin()
{
// Reset flag
WebPost.PerfectSplitPostCandidateSuccess=false;

StringBuilder PostWhat=new StringBuilder();
HttpWebRequest
HttpWRequest=BuildHTTPWebRequest(WebPost.PerfectSp litLoginPage,
WebPost.PerfectSplitCookieJar,
WebPost.PerfectSplitUserAgent,
WebPost.PostRequest,
WebPost.TimeOut,
WebPost.ContentTypeFormEncoded,
false,false);

PostWhat.Append(WebPost.PerfectSplitViewStateLogin );
PostWhat.Append(WebPost.PerfectSplitUsernameContro lTag +
WebPost.PerfectSplitMDUsername);
PostWhat.Append(WebPost.PerfectSplitPasswordContro lTag +
WebPost.PerfectSplitMDPassword);
PostWhat.Append(WebPost.PerfectSplitLoginButtonTag );

// Call a function that does the work to get the request.
if(!MakeWebRequest(HttpWRequest, PostWhat.ToString()))
{
return; // The call failed
}
WebPost.PerfectSplitLoginSuccess=true;
}


/// <summary>
/// Posts a candidate to the perfectsplit website
/// </summary>
/// <param name="PostCandidate">
/// A valid instance of the 'PerfectSplitPostCandidate' class
/// </param>
public static void PerfectSplitMDPostCandidate(PerfectSplitPostCandid ate
PostCandidate)
{
// Reset flag
WebPost.PerfectSplitPostCandidateSuccess=false;

StringBuilder PostWhat=new StringBuilder();
HttpWebRequest
HttpWRequest=BuildHTTPWebRequest(WebPost.PerfectSp litPostCandidatePage,
WebPost.PerfectSplitCookieJar,
WebPost.PerfectSplitUserAgent,
WebPost.PostRequest,
WebPost.TimeOut,
WebPost.ContentTypeFormEncoded,
false,false);


// The server may not understand this new header; disable it
System.Net.ServicePointManager.Expect100Continue=f alse;

PostWhat.Append(WebPost.PerfectSplitViewStatePostC andidate);
PostWhat.Append(PostCandidate.CandidateID);
PostWhat.Append(PostCandidate.Citizenship);
PostWhat.Append(PostCandidate.FirstSpecialty);
PostWhat.Append(PostCandidate.Population);
PostWhat.Append(PostCandidate.SecondSpecialty);
PostWhat.Append(PostCandidate.YearMDEarned);
PostWhat.Append(PostCandidate.Degree);
PostWhat.Append(PostCandidate.BoardStatus);
PostWhat.Append(PostCandidate.Training);
PostWhat.Append(PostCandidate.WhenAvailable);

if(PostCandidate.PracticeA0.IndexOf(PerfectSplitPo stCandidate.PracticeOn)>0)
{
PostWhat.Append(PostCandidate.PracticeA0);
}
if(PostCandidate.PracticeA1.IndexOf(PerfectSplitPo stCandidate.PracticeOn)>0)
{
PostWhat.Append(PostCandidate.PracticeA1);
}
if(PostCandidate.PracticeA2.IndexOf(PerfectSplitPo stCandidate.PracticeOn)>0)
{
PostWhat.Append(PostCandidate.PracticeA2);
}
if(PostCandidate.PracticeA3.IndexOf(PerfectSplitPo stCandidate.PracticeOn)>0)
{
PostWhat.Append(PostCandidate.PracticeA3);
}

PostWhat.Append(PostCandidate.StatesList);
PostWhat.Append(PerfectSplitPostCandidate.PostCand idateButtonTag);
PostWhat.Append(PostCandidate.Comments);
//Call a function that does the work to get the request.
if (!MakeWebRequest(HttpWRequest, PostWhat.ToString()))
{
return; // the call failed
}
WebPost.PerfectSplitPostCandidateSuccess=true;
}


/// <summary>
/// Posts an opening to the perfectsplit website
/// </summary>
/// <param name="PostOpening">
/// A valid instance of the 'PerfectSplitPostOpening' class
/// </param>
public static void PerfectSplitMDPostOpening(PerfectSplitPostOpening
PostOpening)
{
// Reset flag
WebPost.PerfectSplitPostOpeningSuccess=false;

StringBuilder PostWhat=new StringBuilder();
HttpWebRequest
HttpWRequest=BuildHTTPWebRequest(WebPost.PerfectSp litPostOpeningPage,
WebPost.PerfectSplitCookieJar,
WebPost.PerfectSplitUserAgent,
WebPost.PostRequest,
WebPost.TimeOut,
WebPost.ContentTypeFormEncoded,
false,false);


// The server may not understand this new header; disable it
System.Net.ServicePointManager.Expect100Continue=f alse;

PostWhat.Append(WebPost.PerfectSplitViewStatePostO pening);
PostWhat.Append(PostOpening.PositionID);
PostWhat.Append(PostOpening.Citizenship);
PostWhat.Append(PostOpening.FirstSpecialty);
PostWhat.Append(PostOpening.Population);
PostWhat.Append(PostOpening.SecondSpecialty);
PostWhat.Append(PostOpening.State);
PostWhat.Append(PostOpening.Degree);
PostWhat.Append(PostOpening.BoardStatus);
PostWhat.Append(PostOpening.Training);
PostWhat.Append(PostOpening.Fee);

if(PostOpening.PracticeA0.IndexOf(PerfectSplitPost Opening.PracticeOn)>0)
{
PostWhat.Append(PostOpening.PracticeA0);
}
if(PostOpening.PracticeA1.IndexOf(PerfectSplitPost Opening.PracticeOn)>0)
{
PostWhat.Append(PostOpening.PracticeA1);
}
if(PostOpening.PracticeA2.IndexOf(PerfectSplitPost Opening.PracticeOn)>0)
{
PostWhat.Append(PostOpening.PracticeA2);
}
if(PostOpening.PracticeA3.IndexOf(PerfectSplitPost Opening.PracticeOn)>0)
{
PostWhat.Append(PostOpening.PracticeA3);
}

PostWhat.Append(PostOpening.Comments);
PostWhat.Append(PerfectSplitPostOpening.PostPositi onButtonTag);
//Call a function that does the work to get the request.
if (!MakeWebRequest(HttpWRequest, PostWhat.ToString()))
{
return; // the call failed
}
WebPost.PerfectSplitPostOpeningSuccess=true;
}


/// <summary>
/// Removes a candidate from the perfectsplit website
/// </summary>
/// <param name="RemoveCandidate">
/// A valid instance of the 'PerfectSplitRemoveCandidate' class
/// </param>
public static void
PerfectSplitMDRemoveCandidate(PerfectSplitRemoveCa ndidate RemoveCandidate)
{
WebPost.PerfectSplitRemoveCandidateSuccess=false;

int
Count=WebPost.Occurrences(WebPost.ResponseData,Rem oveCandidate.CandidateID);

if(Count>0)
{
for(int Loop=1;Loop<=Count;Loop++)
{
int Start=WebPost.ResponseData.IndexOf(RemoveCandidate .CandidateID,1);
Start=WebPost.ResponseData.IndexOf(PerfectSplitRem oveCandidate.DeleteControlInID,Start);
Start=WebPost.ResponseData.IndexOf(PerfectSplitRem oveCandidate.DeleteControlName,Start
+ RemoveCandidate.CandidateID.Length);
int
End=WebPost.ResponseData.IndexOf(PerfectSplitRemov eCandidate.DeleteControlNameEnd,Start)+(PerfectSpl itRemoveCandidate.DeleteControlNameEnd.Length-2);

RemoveCandidate.ControlFullName=WebPost.ResponseDa ta.Substring(Start,End-Start);
RemoveCandidate.ControlFullName=RemoveCandidate.Co ntrolFullName.Replace(Globals.SymbolConstants.Doll ar,WebPost.EncodedDeleteControlDollar);

StringBuilder PostWhat=new StringBuilder();
HttpWebRequest
HttpWRequest=BuildHTTPWebRequest(WebPost.PerfectSp litMyCandidatesPage,
WebPost.PerfectSplitCookieJar,
WebPost.PerfectSplitUserAgent,
WebPost.PostRequest,
WebPost.TimeOut,
WebPost.ContentTypeFormEncoded,
false,false);

// The server may not understand this new header; disable it
System.Net.ServicePointManager.Expect100Continue=f alse;

PostWhat.Append(WebPost.EventTarget);
PostWhat.Append(RemoveCandidate.ControlFullName);
PostWhat.Append(Globals.SymbolConstants.Ampersand) ;
PostWhat.Append(WebPost.EventArgument);
PostWhat.Append(Globals.SymbolConstants.Ampersand) ;
PostWhat.Append(WebPost.PerfectSplitViewStateMyCan didates);

//Call a function that does the work to get the request.
if (!MakeWebRequest(HttpWRequest, PostWhat.ToString()))
{
return; // the call failed
}
WebPost.PerfectSplitRemoveCandidateSuccess=true;

// Get ViewState for MyCandidates page
// Repeating this here also updates the 'ResponseData' property
// which is needed for this loop
WebPost.PerfectSplitViewStateMyCandidates =
WebPost.GetViewState(WebPost.PerfectSplitMyCandida tesPage,
WebPost.PerfectSplitCookieJar,
WebPost.PerfectSplitUserAgent);
}
}
}

/// <summary>
/// Removes an opening from the perfectsplit website
/// </summary>
/// <param name="RemoveOpening">
/// A valid instance of the 'PerfectSplitRemoveOpening' class
/// </param>
public static void PerfectSplitMDRemoveOpening(PerfectSplitRemoveOpen ing
RemoveOpening)
{
WebPost.PerfectSplitRemoveOpeningSuccess=false;

int
Count=WebPost.Occurrences(WebPost.ResponseData,Rem oveOpening.OpeningID);

if(Count>0)
{
for(int Loop=1;Loop<=Count;Loop++)
{
int Start=WebPost.ResponseData.IndexOf(RemoveOpening.O peningID,1);
Start=WebPost.ResponseData.IndexOf(PerfectSplitRem oveOpening.DeleteControlInID,Start);
Start=WebPost.ResponseData.IndexOf(PerfectSplitRem oveOpening.DeleteControlName,Start
+ RemoveOpening.OpeningID.Length);
int
End=WebPost.ResponseData.IndexOf(PerfectSplitRemov eOpening.DeleteControlNameEnd,Start)+(PerfectSplit RemoveOpening.DeleteControlNameEnd.Length-2);

RemoveOpening.ControlFullName=WebPost.ResponseData .Substring(Start,End-Start);
RemoveOpening.ControlFullName=RemoveOpening.Contro lFullName.Replace(Globals.SymbolConstants.Dollar,W ebPost.EncodedDeleteControlDollar);

StringBuilder PostWhat=new StringBuilder();
HttpWebRequest
HttpWRequest=BuildHTTPWebRequest(WebPost.PerfectSp litMyOpeningsPage,
WebPost.PerfectSplitCookieJar,
WebPost.PerfectSplitUserAgent,
WebPost.PostRequest,
WebPost.TimeOut,
WebPost.ContentTypeFormEncoded,
false,false);

// The server may not understand this new header; disable it
System.Net.ServicePointManager.Expect100Continue=f alse;

PostWhat.Append(WebPost.EventTarget);
PostWhat.Append(RemoveOpening.ControlFullName);
PostWhat.Append(Globals.SymbolConstants.Ampersand) ;
PostWhat.Append(WebPost.EventArgument);
PostWhat.Append(Globals.SymbolConstants.Ampersand) ;
PostWhat.Append(WebPost.PerfectSplitViewStateMyOpe nings);

//Call a function that does the work to get the request.
if (!MakeWebRequest(HttpWRequest, PostWhat.ToString()))
{
return; // the call failed
}
WebPost.PerfectSplitRemoveOpeningSuccess=true;

// Get ViewState for MyOpenings page
// Repeating this here also updates the 'ResponseData' property
// which is needed for this loop
WebPost.PerfectSplitViewStateMyOpenings =
WebPost.GetViewState(WebPost.PerfectSplitMyOpening sPage,
WebPost.PerfectSplitCookieJar,
WebPost.PerfectSplitUserAgent);
}
}
}



/// <summary>
/// Complete the HttpWebRequest
/// </summary>
/// <param name="httpWRequest">
/// The HttpWebRequest object used to get a response from a website
/// </param>
/// <param name="postWhat">
/// The data that is posted to the website
/// </param>
/// <returns></returns>
private static bool MakeWebRequest(HttpWebRequest httpWRequest, string
postWhat)
{
HttpWebResponse HttpWResponse;

// We need to store the data into a byte array
byte[] PostData = System.Text.Encoding.ASCII.GetBytes(postWhat);
httpWRequest.ContentLength = PostData.Length;
Stream TempStream = httpWRequest.GetRequestStream();
// Write the data to be posted to the Request Stream
TempStream.Write(PostData,0,PostData.Length);
TempStream.Close();

// Make the connection to the server
HttpWResponse = (HttpWebResponse)httpWRequest.GetResponse();

// Reset the response object
if(HttpWResponse != null)
{
StreamReader ResponseReader = new
StreamReader(HttpWResponse.GetResponseStream());
// Log response data for use in other capacities (i.e. examine contents)
WebPost.ResponseData = ResponseReader.ReadToEnd().ToString();
HttpWResponse.Close();
HttpWResponse = null;
}
return true;
}






"bruce barker" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> HttpWebRequest will use any port (specify in url) you want but defaults to
> port 80. not sure what your issue is. maybe some sample code.
>
> -- bruce (sqlwork.com)
>
> TC wrote:
>> Hey All,
>>
>> I have some classes that I recently built for a website which uses the
>> HttpWebRequest & HttpWebResponse objects from the System.Net namespace.
>> Basically, the classes rap submitted data up, connect to external
>> websites on external servers and post / remove the data from these other
>> sites.
>>
>> It works fine locally but when uploaded to the BCentral production
>> server, the outgoing requests get shutdown.
>>
>> Apparently, for the System.Net name space, you cannot specify the port.
>> The outgoing port will be dynamic random. It will be the client port and
>> not the service port. The port range can be 1024 and above. It is by
>> design and there is no way you can specify the client port.
>>
>> Now, as for BCentral, they do allow outbound connections but only on the
>> "default" ports such at 80 for http, etc. Every other non-essential
>> port is locked down and they don't open up other ports because of
>> security concerns.
>>
>> Can someone please advise?
>>
>> Thanks,
>>
>> TC



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! ... Outbound Port Getting Shut Down TC ASP .Net Security 2 06-08-2007 06:58 AM
Sporadic Power Down / Shut Down Problems nash123 Computer Support 17 08-24-2005 12:47 AM
Shut down Windows XP - order which it shuts down applications Bun Mui Computer Support 2 05-16-2004 09:10 PM
Port security on a Catalyst 4000 - fails to shut down port Jon Whitear Cisco 2 11-04-2003 11:01 PM
Won't power down when shut down Ray Horton Computer Support 2 08-27-2003 07:29 PM



Advertisments