Link to home
Start Free TrialLog in
Avatar of Opusretis
OpusretisFlag for Switzerland

asked on

ASP.NET Membership Login Programmatically

I've got a ASP.NET Webapplication with ASP.NET Membership Provider for User and Rolemanagement.
There is also an second Project, something like a Webspider.
The Spider should read periodically the content of the Webapplication.
In the Page_Load Event of the Webapp Login-Page I check a Querystring (Something like an API-Key). If this query string is there I use the FormsAuthentication.SetAuthCookie Method to Login a special User. If I test this directly in the browser, the login is working fine and I can access the other sites. If I try to do so with the spider I get only the content of the Login Page, even if I try to access other pages after I did the login. I use for this a WebClient Object:

WebClient client = new WebClient();
string s = client.DownloadString("http://localhost:50125/Account/Login.aspx?Pass=123");
            s = client.DownloadString("http://localhost:50125/Default.aspx");

Open in new window


Is it possible that the WebClient doesn't support the AuthCookie? How can I solve my problem?
ASKER CERTIFIED SOLUTION
Avatar of Gary Davis
Gary Davis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial