Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8193745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:35:18+00:00 2026-06-07T04:35:18+00:00

i try to login into a forum with c# webclient to get userrelevant informations

  • 0

i try to login into a forum with c# webclient to get userrelevant informations
my problem is the login fails
i tried to submit all needed data via post

my actual code:

        var url = new Uri("http://www.hardwareluxx.de/community/");
        string user = Properties.Resources.username;
        string pass = Properties.Resources.password;
        var client = new CookieAwareWebClient();
        client.BaseAddress = @"http://www.hardwareluxx.de/community/";


        var document = new HtmlDocument();
        document.Load(new MemoryStream(client.DownloadData("index.php")));

        postData = new NameValueCollection();

        postData.Add("vb_login_username", user);
        postData.Add("cookieuser", "1");
        postData.Add("vb_login_password", "");
        postData.Add("s", "");
        postData.Add("securitytoken", "guest");
        postData.Add("do", "login");
        postData.Add("vb_login_md5password", GetMd5Hash(pass));
        postData.Add("vb_login_md5password_utf", GetMd5Hash(pass));

        document.Load(new MemoryStream(client.UploadValues(url + "login.php?do=login", postData)));

and a small helping method to get md5 hashes needed for the login:

public static string GetMd5Hash(string TextToHash)
    {
        //Prüfen ob Daten übergeben wurden.
        if (string.IsNullOrEmpty(TextToHash))
        {
            return string.Empty;
        }

        //MD5 Hash aus dem String berechnen. Dazu muss der string in ein Byte[]
        //zerlegt werden. Danach muss das Resultat wieder zurück in ein string.
        MD5 md5 = new MD5CryptoServiceProvider();
        byte[] textToHash = Encoding.Default.GetBytes(TextToHash);
        byte[] result = md5.ComputeHash(textToHash);

        return BitConverter.ToString(result);
    }

and the webclient where the cookie is stored as well:

public class CookieAwareWebClient : WebClient
{
    private readonly CookieContainer _cookie = new CookieContainer();

    protected override WebRequest GetWebRequest(Uri address)
    {
        WebRequest request = base.GetWebRequest(address);
        if (request is HttpWebRequest)
        {
            (request as HttpWebRequest).CookieContainer = _cookie;
        }
        return request;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:35:19+00:00Added an answer on June 7, 2026 at 4:35 am

    You should pass the credentials to the HttpWebRequest instance using request.Credentials

    public class CookieAwareWebClient : WebClient
    {
      private readonly CookieContainer _cookie = new CookieContainer();
      private string userName;
      private string password;
    
      public CookieAwareWebClient(string user, string pass) 
      {
        userName = user;
        password = pass; 
      }
    
      protected override WebRequest GetWebRequest(Uri address)
      {
        WebRequest request = base.GetWebRequest(address);
    
        if (!string.IsNullOrEmpty(userName)) 
        {
          request.Credentials = new NetworkCredential(userName, password);
        }
    
        if (request is HttpWebRequest)
        {
          (request as HttpWebRequest).CookieContainer = _cookie;
        }
    
        return request;
      }
    }
    
    string user = Properties.Resources.username;
    string pass = Properties.Resources.password;
    
    var client = new CookieAwareWebClient(user, pass);
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I didn't get any responses from the asp.net forum, so I thought I'd try
When I try to login to our WSS demo site the authentication popup forces
I try to provide a login with the facebook-php-sdk. But, when I click on
When try to access site i created after 3 login attempts it gives unauthorised
I cannot login using email in CakePHP 2.1, when i try with username then
I am working in a Login page and teh logic is like -> try
I'm creating a login for a website using PHP but when I try to
I'm try to use drupal open id module. When i used to login using
I've been trying to override the file login.xml but no matter what I try,
I'm trying to set up a simple login using AuthLogic into my User table.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.