I have been looking for more information on how to login to an aspx based website from a C# NET application, but everything I find is based on creating aspx login systems in C# instead. I would like the user to be able to login to an .aspx site, having nothing to do with any actual ASP code in my project. Can anyone provide more information on this?
-
are you using WebClient on your app and you want to download something from the web app ?Felice Pollano– Felice Pollano2011-02-26 09:29:31 +00:00Commented Feb 26, 2011 at 9:29
-
1Can you re-word your question a bit please. Your title says ASP but the first sentence is confusing.Shiv Kumar– Shiv Kumar2011-02-26 09:29:52 +00:00Commented Feb 26, 2011 at 9:29
-
2What kind of authentication is your ASP.NET application using? Windows Authentication, ASP.NET authentication (such as ASP.NET Membership) etc. Each authentication protocol is different. Please also explain what you mean by C#.NET application. Is that a Windows/ WPF application? Do you need to run it from the same network as your ASP.NET application or is it over the Internet?Shiv Kumar– Shiv Kumar2011-02-26 09:33:34 +00:00Commented Feb 26, 2011 at 9:33
-
Sorry about that. I am not sure what kind of Authentication it is using, I will check. It is a Windows Application I am developing, and no, it is on a seperate network so it is over the internet. The site I want to login to is my.xfactorservers.com/Templates/Default/login.aspxMichael Pfiffer– Michael Pfiffer2011-02-26 09:45:00 +00:00Commented Feb 26, 2011 at 9:45
-
Do you want to visually render that site in your Windows client (using System.Windows.Forms.WebBrowser for example) or do you want to perform background, "invisible" requests (using System.Net.HttpWebRequest for instance)?Maxim Gueivandov– Maxim Gueivandov2011-02-26 10:06:26 +00:00Commented Feb 26, 2011 at 10:06
|
Show 1 more comment
1 Answer
In most basic cases, you will have to:
- Identify which POST parameters are used to represent the login and the password
- Make a POST request to the login page providing these parameters
- Get all cookies from the response and ensure to provide them during your subsequent requests
Check the following page for an example of implementation: Fetching ASP.NET authenticated page with HTTPWebRequest