How to programatically log into a forms authenticated website?

Posted on 2005-04-06
Last Modified: 2008-02-01
I have a web site that we built, but I now need to be able to preload information into the web site by a third-party application using a web service.  I need to be able to

1.  Programmatically log into the website (the website uses forms authentication) and load an XML file into the website via a web service.

This should be easy a simple web service that says (and secured using SSL) should work.
eg.  LoadXML (string userName, string password, string XML)

2.  Start up the website in a browser (already logged in for the user) and goto an aspx page that presents the loaded information to the user.

This is a little more confusing, how do I programmatically log a user in?  At first I thought of having a web service like above, and once the credentials are authenticated, I would redirect the user to the website page using the session information.  But this doesn't seem to be the right approach...since web services don't have UI.

I don't want to encode the username/password in the URL in plain text....Can anyone help me with this?  


Question by:andrewting

    Author Comment


    This article seems to explain what I need...

    Author Comment


    For anyone interested I solved my problem by building a web service that returns the URL string with the user id and password encrypted into it.

    Instead of

    You end up with

    The web site knows how to parse the "combined" parameter to get the user id and password.  My login page gets the credentials from the encrypted parameter, and authenticates and sets the forms authentication ticket and then redirects the browser to the data display page.  This seems to work well for me.

    Encryption algorithm I used was from here:


    Author Comment


    Can someone help me close this issue now since I found the answer myself?

    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    761 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

    12 Experts available now in Live!

    Get 1:1 Help Now