Jump to content

[Answered] Why Is My Asp.net Program Can Not Access Port 10001?


loveloli

Recommended Posts

Forgive my poor English

 

I have a program that needs to access an external website but its port is not 80 but 10001

For example: eg.test.com:10001, but I found that the program can not connect, I also tried to access ordinary website: www.google.com operating normally

So I would like to ask a solution

Here is my part of the program:

 

static public string Login(string LoginId, string PassWord)

{

HttpWebRequest Request = WebRequest.Create("http://eg.test.com:10001") as HttpWebRequest;

Request.Method = "POST";

Request.KeepAlive = true;

Request.ContentType = "application/x-www-form-urlencoded";

ASCIIEncoding Encoder = new ASCIIEncoding();

byte[] bytes = Encoder.GetBytes("login_id=" + LoginId + "&password=" + PassWord);

Request.ContentLength = bytes.Length;

Stream bw = Request.GetRequestStream();

bw.Write(bytes, 0, bytes.Length);

bw.Flush();

bw.Close();

HttpWebResponse Response = Request.GetResponse() as HttpWebResponse;

//DeflateStream ds = new DeflateStream(Response.GetResponseStream(), CompressionMode.Decompress);

StreamReader sr = new StreamReader(Response.GetResponseStream(), Encoding.UTF8);

string data = sr.ReadToEnd();

Response.Close();

return data;

}

Link to comment
Share on other sites

I'm stuck In web.config settings, at least you can load website page...

 

can I look at your web.config?

 

Thanks.

 

Forgive my poor English I have a program that needs to access an external website but its port is not 80 but 10001 For example: eg.test.com:10001, but I found that the program can not connect, I also tried to access ordinary website: www.google.com operating normally So I would like to ask a solution Here is my part of the program: static public string Login(string LoginId, string PassWord) { HttpWebRequest Request = WebRequest.Create("http://eg.test.com:10001") as HttpWebRequest; Request.Method = "POST"; Request.KeepAlive = true; Request.ContentType = "application/x-www-form-urlencoded"; ASCIIEncoding Encoder = new ASCIIEncoding(); byte[] bytes = Encoder.GetBytes("login_id=" + LoginId + "&password=" + PassWord); Request.ContentLength = bytes.Length; Stream bw = Request.GetRequestStream(); bw.Write(bytes, 0, bytes.Length); bw.Flush(); bw.Close(); HttpWebResponse Response = Request.GetResponse() as HttpWebResponse; //DeflateStream ds = new DeflateStream(Response.GetResponseStream(), CompressionMode.Decompress); StreamReader sr = new StreamReader(Response.GetResponseStream(), Encoding.UTF8); string data = sr.ReadToEnd(); Response.Close(); return data; }
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...