Note that there are some explanatory texts on larger screens.

plurals
  1. POWhats The Best Approach For a Lib That Extends HttpWebRequest Class?
    primarykey
    data
    text
    <p>I just started to write a <code>Class Library</code> in C# that will implement Gets, Posts (Http Requests of Post and Gets) and oAuth (Authentication method using tokens logic).</p> <p>Currently, every aplication me and my colleagues write have its own "HttpMethods" class that is responsible for executing Gets and Posts.</p> <p>Here is a quick Example of a Get That we have :</p> <pre><code> 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; } </code></pre> <p>My question is : Which will be the best approach for us to addopt ? We want to have our own lib that will use the <code>HttpWebRequest object</code>,ending to something just like this:</p> <pre><code>MyOwnDll.MyOwnClassResponsibleForWebRequests.Get (Parameters) </code></pre> <p>Same for a Post Method.</p> <p>What should i do ?</p> <p>Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload