473,624 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble with ContentType multipart/form-data

Hi,

I am working on (read that - upgrading) an application. This
application creates an HTTPWebRequest object, populates it with values
which are then sucked out of the Request.Form object (eg someVariable =
Request.Form)

My problem is that the app doesn't allow input of non-ASCII data in the
form. To resolve this I have replace the ContentType from
"applicatio n/x-www-form-urlencoded" to "multipart/form-data".

Now I can accept non-ASCII characters however the Request.Form is
empty. When I swap back to "applicatio n/x-www-form-urlencoded" for the
ContentType all is well but I have customers from around the world and
some of them use non-ASCII charaters and the way the code is written I
need data in the Request.Form.

Am I missing something? Can I populate the Form using the
"multipart/form-data" ContentType?

Is there another way to pass data into the form besides the way I am
doing it (below).

<code>
// create the request object
HttpWebRequest request1 = (HttpWebRequest ) WebRequest.Crea te(url + "?"
+ base.Request.Qu eryString);

// create the values to insert into the request object
objArray1 = new object[3] { "Value1=", value1, "&Value2=", value2,
"&Value3=",valu e3} ;
string text1 = string.Concat(o bjArray1);
text1 = text1.Replace(" ", "%20");

request1.Conten tLength = text1.Length;

// here is the trouble
request1.Conten tType = "multipart/form-data"; //
"applicatio n/x-www-form-urlencoded" works fine

request1.Method = "POST";

// At this point I insert the new "Values" in to the form (works unless
I use "multipart/form-data")
StreamWriter writer1 = new StreamWriter(re quest1.GetReque stStream());

writer1.Write(t ext1); // text1 was populated earlier with the new
values to insert into the form
</code>

At this point I can get a response object so I can look at the request:
<code>
HttpWebResponse response1 = (HttpWebRespons e) request1.GetRes ponse();
stream1 = response1.GetRe sponseStream();
reader1 = new StreamReader(st ream1, Encoding.ASCII) ;
string text3 = reader1.ReadToE nd();
</code>

I can now look into text3 to tell whether the data from text1 (the
values to insert) has made it into the Request.Form object.

Thats how I do it.

Any ideas or suggestions would be great!

Dec 1 '06 #1
0 1707

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3021
by: Weston C | last post by:
I'm having some trouble with Mail_Mime... it looks as if it isn't handling the creation of headers transparently. Here's what I'm essentially doing: $MimeMesg = new Mail_mime(); $MimeMesg->setTxtBody($MessageBody); $MimeMesg->setHTMLBody($filledInTemplate); $MimeMesg->addHTMLImage($entry,'image/jpeg'); $headers = array( 'From' => $From, 'Subject' => $Subject);
4
2808
by: John Fereira | last post by:
So, one of the limitations of multipart-form handling is that when an <input type="file" ..> tag is used it will bring up a window which allows a user to select a file for upload but won't allow the user to select multiple files. As you may know, the tag produces a text input field with an adjacent button for selecting a file from the local file system. As I would like to be able to allow the user to upload an arbitrary number of files...
0
1229
by: Lone | last post by:
Hi all, Im trying to stream an RealPlayer file to the client. In classis asp, the code was as such: <% Response.Buffer=True Response.ContentType="audio/x-pn-realaudio" %> rtsp://myserver/filename.ra?start=""&end=""&title="Test"
3
1569
by: ad | last post by:
I create a MemoryStream form a dataset: MemoryStream sm= new MemoryStream(); dsHealth.WriteXml(sm); I use Response.Write() to send this XML MemoryStream as file to client. What is the ContentType of Response I must set?
4
5316
by: yoram.ayalon | last post by:
Hi, I need to create a multipart request to UPS manifest upload electronic service. UPS wants the request to consist of a series of headers and bodies, and its not clear how can I use the HttpWebRequest object to do this. there is the Headers collection, but I don't think it will give me the control we need. is there a low-level way to create the entire stream and attach to the object before posting ?
4
3107
by: DMG | last post by:
I have <identity impersonate = "true" /& <authentication mode="Windows"/in the web.config. This is a 2.0 site. My Goal: I want to simply have the user browse to a file on a mapped drive and get the UNC for that file and eventually save that unc path to the database as a link. The problem is depending on office we have the same drive letter mapped to different servers. My current test works when I run everything locally and maps...
2
6302
by: madmak | last post by:
Hi, I am a noob with PHP and need some asistance regarding PHP and lotus notes. I am trying to create a multipart message in PHP to send mail via lotus notes. Here is the code snippet. <?php ---some code here -- $session_notes = new COM("Lotus.NotesSession"); $session_notes->Initialize("<password>");
4
61833
by: Bjorn Sagbakken | last post by:
With ASP.NET 2.0 I'm trying to display the pdf file directly in the client browser, but I only get a download dialogue box. Downloading the file works fine, but I want to view the PDF directly. I get the same response with: Response.ContentType="Application/X-unknown" which is more understandable. The Response.ContentType="Application/pdf" doesn't seem to tell the browser
0
1502
by: pezkel | last post by:
Hi, For the last two weeks I have been looking for a solid way to create an asp page that can upload a binary file and an xml file in a multipart message to a third party website. I am on the verge of giving (and cracking) up so I would appreciate any pointers. I have used: http://www.motobit.com/tips/detpg_uploadvbsie/ and end up with the problem that I have a byte array for the binary file and a string for the xml. I have tried...
5
2817
by: hawkeye parker | last post by:
Hello, IIS 6.0 server, .Net 2.0. I have a file download architecture which redirects file download requests to a custom server-side HttpHandler. The handler gets a stream over the file and "returns" the file via HttpContext.Response.OutputStream.Write. This works fine in IE, but with Firefox, I get different behavior: I see no "save as" dialog for the file download ("Always ask me where
0
8233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8675
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8334
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8474
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6108
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2604
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.