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

  • Home
  • SEARCH
  • 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 8772517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:03:17+00:00 2026-06-13T18:03:17+00:00

Im getting a strange error sometimes on my httpwebrequests. Error im getting: ArgumentException was

  • 0

Im getting a strange error sometimes on my httpwebrequests.

Error im getting:

ArgumentException was unhandled by user code
'' is not a supported encoding name.

Code i am running:

            try
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            request.Timeout = 3000;
            request.ReadWriteTimeout = 3000;
            request.Proxy = new WebProxy(p.ToString(), true);

            response = (HttpWebResponse)request.GetResponse();
            Encoding responseEncoding = Encoding.GetEncoding(response.CharacterSet);
            using (StreamReader sr = new StreamReader(response.GetResponseStream(), responseEncoding))
            {
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    // do stuff
                }
            }


        }
        catch (WebException wexc1)
        {
            if (wexc1.Status == WebExceptionStatus.ProtocolError)
            {
                return false;
            }

        }
        finally
        {
            if (response != null)
                response.Close();
        }

It doesent happend all the time its like 1 out of 500 requests. It feels like the code is unable to determine the actual encoding.. but how would i handle this?

The error currently makes the application crash

  • 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-13T18:03:18+00:00Added an answer on June 13, 2026 at 6:03 pm

    I assume that the exception is thrown in the line:

    Encoding responseEncoding = Encoding.GetEncoding(response.CharacterSet);
    

    As a quick advice I would suggest setting Encoding.UTF8 or response.ContentEncoding as the encoding of the stream and not relying on response.CharacterSet().

    CharacterSet is a WebName (e.g. Encoding.UTF8.WebName), not a proper name of the encoding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am getting a strange bundler error when running bundle pack with bundler 0.9.12
I am getting a strange error in Firebug, that I am not getting in
I'm getting a strange error message in SpringSource Tool Suite (eclipse) when I try
Im getting a strange error when im compiling my code on a server and
I'm getting a strange error when running cap deploy:setup: cap deploy:setup Using ActiveModel validations.
I am getting a strange error on Android Market. I am not able to
I'm getting this strange error when I try connect to my WCF with webHttpBinding
I'm getting a strange error from the Python interpreter when I run this code:
This is a really strange error I have been getting sometimes with SOME libraries
I'm getting a strange error with the below code. No column was specified for

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.