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 3597780
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:09:41+00:00 2026-05-18T20:09:41+00:00

the problem is the httpwebrequest method in my c# program. visual studio gives it

  • 0

the problem is the httpwebrequest method in my c# program. visual studio gives it a metric of 60, thats pretty lame.. so how can i program it more efficient? (:

my actual code:

public string httpRequest(string url)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.Method = "GET";
        request.Proxy = WebRequest.DefaultWebProxy;
        request.MediaType = "HTTP/1.1";
        request.ContentType = "text/xml";
        request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12";

        using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            using(StreamReader streamr = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
                String sresp = streamr.ReadToEnd();
        return sresp;
    }

thanks for helping. 😉

  • 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-05-18T20:09:41+00:00Added an answer on May 18, 2026 at 8:09 pm

    Well, firstly I wouldnt let a number rule my code 🙂

    However, using WebClient may simplify things quite a bit – less code to be counted. I’m not at a PC but that looks like a single DownloadString call, plus a few request headers.

    http://msdn.microsoft.com/en-us/library/fhd1f0sw(v=VS.100).aspx

    Oh, and add some using statements around all the IDisposable objects you create.

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

Sidebar

Related Questions

Im stuck on this httpWebRequest problem. I need to send XML to a website.
My problem goes something like this: HttpWebRequest request; try { request = (HttpWebRequest) WebRequest.Create(url);
I have written a web scraping program to go to a list of pages
I have an old C# program that is being ported to Python 3 for
I'm narrowing in on an underlying problem related to two prior questions. Basically, I've
We've got a .NET 2.0 WinForms app that needs to upload files to an
I need to read webpage and store its content in string for further processing.
I had a project that required posting a 2.5 million character QueryString to a
I've hit a wall on POST'ing data to a webform :( Below is the
I am trying to make an Http POST to an Apache web server. I

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.