473,379 Members | 1,235 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Help! ... Outbound Port Getting Shut Down

TC
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
Jun 8 '07 #1
3 1910
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

Jun 8 '07 #2
TC
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" <no****@nospam.comwrote in message
news:Oj*************@TK2MSFTNGP06.phx.gbl...
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

Jun 8 '07 #3
TC
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" <no****@nospam.comwrote in message
news:Oj*************@TK2MSFTNGP06.phx.gbl...
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

Jun 8 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help...
9
by: Tom | last post by:
A question for gui application programmers. . . I 've got some GUI programs, written in Python/wxPython, and I've got a help button and a help menu item. Also, I've got a compiled file made with...
4
by: Sarir Khamsi | last post by:
Is there a way to get help the way you get it from the Python interpreter (eg, 'help(dir)' gives help on the 'dir' command) in the module cmd.Cmd? I know how to add commands and help text to...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
3
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With...
7
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available...
5
by: Steve | last post by:
I have written a help file (chm) for a DLL and referenced it using Help.ShowHelp My expectation is that a developer using my DLL would be able to access this help file during his development time...
8
by: Mark | last post by:
I have loaded Visual Studio .net on my home computer and my laptop, but my home computer has an abbreviated help screen not 2% of the help on my laptop. All the settings look the same on both...
1
by: trunxnirvana007 | last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 'UPGRADE_WARNING: Couldn't resolve...
0
by: hitencontractor | last post by:
I am working on .NET Version 2003 making an SDI application that calls MS Excel 2003. I added a menu item called "MyApp Help" in the end of the menu bar to show Help-> About. The application...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.