Richmond
Richmond

Reputation: 1

Remotely authenticate into ASP.NET page

I'm trying to remotely log into some ASP.NET page with username and password. I was trying to do it by creating HttpWebRequest object and send it with parameters using POST method, but with no success.

Is there any other way? Or maybe I'm doing something wrong, could someone post example here? The page I am trying to access is ASP.NET WebForms page (with postbacks and stuff).

Thank You in advance.

Upvotes: 0

Views: 295

Answers (1)

akton
akton

Reputation: 14386

It depends what type of authentication you are using. If you are using basic or NTLM authentication, you set the Credentials property of the HttpWebRequest. Using request.Credentials = CredentialCache.DefaultCredentials usually works. The example on the previous link should get you started.

If you are using Forms authentication, it depends on the design of your login page. It may be easier to create a web method you pass the credentials to which returns a cookie of the correct format (or whatever you use for subsequent authentication).

As usual, remember that passing credentials unencrypted (e.g. basic authentication or forms authentication using the idea suggest above) allows an malicious user to sniff the credentials off the network.

Upvotes: 2

Related Questions