Solved

ASP.NET Membership Login Programmatically

Posted on 2014-11-07
1
330 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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now