Solved

ASP.NET Membership Login Programmatically

Posted on 2014-11-07
1
344 Views
Last Modified: 2014-11-09
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?
0
Comment
Question by:Opusretis
1 Comment
 
LVL 18

Accepted Solution

by:
Gary Davis earned 500 total points
ID: 40430266
Your request to log on will receive the authentication cookie which your subsequent requests would have to return to the server just like a browser would. That way, the subsequent requests will be authenticated. Also, the same with the sessionid cookie if necessary so you maintain your session.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question