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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:57:40+00:00 2026-05-28T01:57:40+00:00

I am writing a .dll that will execute Gets and Posts . In order

  • 0

I am writing a .dll that will execute Gets and Posts.
In order to do so, i created this class:

public class BDCWebRequests
{
    // private attributes
    private static CookieContainer m_CookieJar;
    private static HttpWebRequest  m_HttpWebRequest;
    private static string          m_defaultUserAgent      = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.107 Safari/535.1";
    private static string          m_defaultContentType    = "application/x-www-form-urlencoded";

    // Public Properties
    public HttpWebRequest InternalWebRequest
    {
        get { return m_HttpWebRequest; }
    }

    /// <summary>
    /// Class Constructor
    /// </summary>
    public BDCWebRequests()
    {
        m_CookieJar = new CookieContainer();
    }

   // Methods Come Here...
}

What i am trying to achieve is a way for the user of this lib to configure the request properly using the “InternalWebRequest” property.

The usage would be something like this:

BDCWebRequests myInstance = new BDCWebRequests();
myInstance.InternalWebRequest.Referer = "refererUrl";
myInstance.AllowAutoRedirect          = true;
myInstance.Host                       = "hostUrl";

After doing so, there are Posts and Get Methods ( Here is the GET as an Example )

 public string Get(string url)
    {
        try
        {
            // Creating instance of HttpWebRequest based on URL received
            m_HttpWebRequest = (HttpWebRequest) WebRequest.Create (url);

            m_HttpWebRequest.Method                        = "GET";
            m_HttpWebRequest.UserAgent                     = m_defaultUserAgent;

            // Execute web request and wait for response
            using (HttpWebResponse resp = (HttpWebResponse) m_HttpWebRequest.GetResponse())
            {
              return new StreamReader(resp.GetResponseStream()).ReadToEnd();
            }

        }
        catch (Exception ex)
        {
            LogWriter.Error(ex);
        }

        return String.Empty;
    } 

Usage:

myInstance.Get("UrlForTheRequest");

Main Issue:
I am having problem when a user Executes a GET or a POST,and after this, he tries to change any attribute of the internal instance of HttpWebRequest using the public property.

If a user Calls a GET for example,and after that he tries to :

myInstance.InternalWebRequest.Host = "", for example, it throws an error:
"this property cannot be set after writing has started"

Any idea of how to Logically implement it so that a user can :

1 – Configure the request anywhere, anytime without getting me this error
2 – Execute Gets and Posts using the previously Configured Request ?

Sorry for that Long Question, thanks in advance for the patience.
Please, do not TL:DR 🙂

  • 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-28T01:57:41+00:00Added an answer on May 28, 2026 at 1:57 am

    Simple: the moment you’ve sent the request, read all the required data from the response, and then create a new request, and copy all relevant parameters from old request to it.

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

Sidebar

Related Questions

I have been writing DLL on C++, that will be use in C#. DLL
I'm writing a web application that will have plugins. The plugins will be .DLL
I have a C++ class I'm writing now that will be used all over
I am writing a DLL function called ADAuthenticate that will authenticate a user against
For my CMS application I'm writing a DLL that I will include into my
I am writing a Win32 DLL library that can be redistributed. I am using
I'm writing some plugin code in a dll that is called by a host
I am writing a custom c# HttpModule that will handle requests from all file
That's what I wanna achieve : There will be dll which contains only methods
I'm writing an application that will need to reboot the Windows machine the code

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.