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) [quoted text, click to view] 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 >
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
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.NoCache); // The server may not understand this new header; disable it System.Net.ServicePointManager.Expect100Continue=false; 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.PerfectSplitLoginPage, WebPost.PerfectSplitCookieJar, WebPost.PerfectSplitUserAgent, WebPost.PostRequest, WebPost.TimeOut, WebPost.ContentTypeFormEncoded, false,false); PostWhat.Append(WebPost.PerfectSplitViewStateLogin); PostWhat.Append(WebPost.PerfectSplitUsernameControlTag + WebPost.PerfectSplitMDUsername); PostWhat.Append(WebPost.PerfectSplitPasswordControlTag + 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(PerfectSplitPostCandidate PostCandidate) { // Reset flag WebPost.PerfectSplitPostCandidateSuccess=false; StringBuilder PostWhat=new StringBuilder(); HttpWebRequest HttpWRequest=BuildHTTPWebRequest(WebPost.PerfectSplitPostCandidatePage, 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=false; PostWhat.Append(WebPost.PerfectSplitViewStatePostCandidate); 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(PerfectSplitPostCandidate.PracticeOn)>0) { PostWhat.Append(PostCandidate.PracticeA0); } if(PostCandidate.PracticeA1.IndexOf(PerfectSplitPostCandidate.PracticeOn)>0) { PostWhat.Append(PostCandidate.PracticeA1); } if(PostCandidate.PracticeA2.IndexOf(PerfectSplitPostCandidate.PracticeOn)>0) { PostWhat.Append(PostCandidate.PracticeA2); } if(PostCandidate.PracticeA3.IndexOf(PerfectSplitPostCandidate.PracticeOn)>0) { PostWhat.Append(PostCandidate.PracticeA3); } PostWhat.Append(PostCandidate.StatesList); PostWhat.Append(PerfectSplitPostCandidate.PostCandidateButtonTag); 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.PerfectSplitPostOpeningPage, 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=false; PostWhat.Append(WebPost.PerfectSplitViewStatePostOpening); 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);
Don't see what you're looking for? Try a search.
|