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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:54:03+00:00 2026-05-10T19:54:03+00:00

I am trying to fill a form in a php application from a C#

  • 0

I am trying to fill a form in a php application from a C# client (Outlook addin). I used Fiddler to see the original request from within the php application and the form is transmitted as a multipart/form. Unfortunately .Net does not come with native support for this type of forms (WebClient has only a method for uploading a file). Does anybody know a library or has some code to achieve this? I want to post different values and additionally (but only sometimes) a file.

Thanks for your help, Sebastian

  • 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. 2026-05-10T19:54:03+00:00Added an answer on May 10, 2026 at 7:54 pm

    This is cut and pasted from some sample code I wrote, hopefully it should give the basics. It only supports File data and form-data at the moment.

    public class PostData {      private List<PostDataParam> m_Params;      public List<PostDataParam> Params     {         get { return m_Params; }         set { m_Params = value; }     }      public PostData()     {         m_Params = new List<PostDataParam>();          // Add sample param         m_Params.Add(new PostDataParam('email', 'MyEmail', PostDataParamType.Field));     }       /// <summary>     /// Returns the parameters array formatted for multi-part/form data     /// </summary>     /// <returns></returns>     public string GetPostData()     {         // Get boundary, default is --AaB03x         string boundary = ConfigurationManager.AppSettings['ContentBoundary'].ToString();          StringBuilder sb = new StringBuilder();         foreach (PostDataParam p in m_Params)         {             sb.AppendLine(boundary);              if (p.Type == PostDataParamType.File)             {                 sb.AppendLine(string.Format('Content-Disposition: file; name=\'{0}\'; filename=\'{1}\'', p.Name, p.FileName));                 sb.AppendLine('Content-Type: text/plain');                 sb.AppendLine();                 sb.AppendLine(p.Value);                              }             else             {                 sb.AppendLine(string.Format('Content-Disposition: form-data; name=\'{0}\'', p.Name));                 sb.AppendLine();                 sb.AppendLine(p.Value);             }         }          sb.AppendLine(boundary);          return sb.ToString();                } }  public enum PostDataParamType {     Field,     File }  public class PostDataParam {       public PostDataParam(string name, string value, PostDataParamType type)     {         Name = name;         Value = value;         Type = type;     }      public string Name;     public string FileName;     public string Value;     public PostDataParamType Type; } 

    To send the data you then need to:

    HttpWebRequest oRequest = null; oRequest = (HttpWebRequest)HttpWebRequest.Create(oURL.URL); oRequest.ContentType = 'multipart/form-data';                        oRequest.Method = 'POST'; PostData pData = new PostData();  byte[] buffer = encoding.GetBytes(pData.GetPostData());  // Set content length of our data oRequest.ContentLength = buffer.Length;  // Dump our buffered postdata to the stream, booyah oStream = oRequest.GetRequestStream(); oStream.Write(buffer, 0, buffer.Length); oStream.Close();  // get the response oResponse = (HttpWebResponse)oRequest.GetResponse(); 

    Hope thats clear, i’ve cut and pasted from a few sources to get that tidier.

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

Sidebar

Ask A Question

Stats

  • Questions 57k
  • Answers 57k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I don't think you need to maintain an 'all' field.… May 11, 2026 at 8:31 am
  • added an answer I'm not sure which version of graphics.h you happen to… May 11, 2026 at 8:31 am
  • added an answer If I've got the right end of your stick the… May 11, 2026 at 8:31 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

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.

      Related Questions

      No related questions found