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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:04:43+00:00 2026-05-27T23:04:43+00:00

I just started to write a Class Library in C# that will implement Gets,

  • 0

I just started to write a Class Library in C# that will implement Gets, Posts (Http Requests of Post and Gets) and oAuth (Authentication method using tokens logic).

Currently, every aplication me and my colleagues write have its own “HttpMethods” class that is responsible for executing Gets and Posts.

Here is a quick Example of a Get That we have :

 public string Get(string url, string refererPage = "")
    {
        string response = null;

        try
        {
            // Web request
            HttpWebRequest request               = (HttpWebRequest)WebRequest.Create(url);
            request.Timeout                      = m_timeout;
            request.Method                       = "GET";
            request.Referer                      = refererPage;
            request.CookieContainer              = m_CookieJar;
            request.Accept                       = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
            request.ServicePoint.ConnectionLimit = Consts.CONNECTIONS_LIMIT;
            request.UserAgent                    = Consts.URI_USER_AGENT;
            request.AllowAutoRedirect            = true;
            request.Host                         = Consts.API_HOST;

            // Web response
            using (HttpWebResponse resp = (HttpWebResponse)request.GetResponse())
                response = new StreamReader(resp.GetResponseStream()).ReadToEnd();
        }
        catch (Exception ex)
        {
            LogWriter.Error(ex);
        }

        return response;   
    }

My question is : Which will be the best approach for us to addopt ?
We want to have our own lib that will use the HttpWebRequest object,ending to something just like this:

MyOwnDll.MyOwnClassResponsibleForWebRequests.Get (Parameters)

Same for a Post Method.

What should i do ?

Thanks in advance

  • 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-27T23:04:44+00:00Added an answer on May 27, 2026 at 11:04 pm

    I think you should follow Factory Pattern.

    Something like this:

    public class MyOwnClassResponsibleForWebRequests
    {
       private MyOwnClassResponsibleForWebRequests(){}
    
       public HttpRequest Get(Params)
       {
          HttpRequestobj hr = new HttpRequest();
          .....your code
          return hr; //or make request and return result
       }
    }
    

    or you can make the request itself and return the result instead of HttpRequest object.

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

Sidebar

Related Questions

I just started with a project that requires me to write to PDF file.
I want to write a Java class that will take a CSV file and
Just started getting a bunch of errors on our C# .Net app that seemed
Just started with JQuery and I've managed to pass a parameter using POST, firebug
I just started programming in Xcode and I'm trying to write an iphone application.
I just started to learn Android, I'm trying to write a widget which is
I'm trying to write a small class library for a C++ course. I was
I've just started to write an application using the latest version of Rails and
As you know, PHP class has private, public and protected keywords. I just started
I am college student (computer science) and have just started a C# programming class.

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.