Posting to HTTPS

D

Denise

I am developing a web application in ASP.Net for a client using C#. One of
my tasks is to create a link from our site to an external website.
Currently, this external site has a login page with username and password
fields.

I have a cross-reference table of user names and passwords that can be used
to log the user in to this site from our ASP.Net site. We want this process
to be seemless to the user - to enter his username and password into the
login page without the user even seeing the page. The external site is NOT
ASP.

Is this possible and does anyone have some direction as to how? I have done
some searching and have some created some code, but I keep getting errros
like
Unauthorized or Method Not Allowed.

Since I have never attempted this, I have no idea if the code below is
correct, but it was my first attempt:

HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("https://xyz.net//HostedSites/index.php");
request.Method = "POST";
string body = "?userName=abc&userPwd=pass1;
byte[] bytes = Encoding.ASCII.GetBytes(body);
request.ContentLength = bytes.Length;
Stream stream = request.GetRequestStream();
stream.Write(bytes, 0, bytes.Length);
HttpWebResponse response = (HttpWebResponse) request.GetResponse();

Thanks,
Denise
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,060
Latest member
BuyKetozenseACV

Latest Threads

Top