相关疑难解决方法(0)

content-type和enctype之间有什么区别

对于HTML表单.我很困惑,我正在尝试设置enctype ='application/octet-stream',但服务器接收到content-type ='application/x-www-form-urlencoded'(默认值)的请求.

html forms gwt

10
推荐指数
1
解决办法
5526
查看次数

在单个 HTTPWebRequest 中上传多个文件

我创建了一个接受两件事的服务:

1) 称为“类型”的主体参数。

2) 要上传的 csv 文件。

我正在像这样在服务器端阅读这两件事:

 //Read body params
 string type = HttpContext.Current.Request.Form["type"];

 //read uploaded csv file
 Stream csvStream = HttpContext.Current.Request.Files[0].InputStream;
Run Code Online (Sandbox Code Playgroud)

我如何测试这个,我正在使用Fiddler来测试这个,但我一次只能发送一个东西(类型或文件),因为这两个东西都是不同的内容类型,我如何使用内容类型multipart/form-dataapplication/x-www-form-urlencoded同时进行。

即使我使用此代码

    public static void PostDataCSV()
    {
        //open the sample csv file
        byte[] fileToSend = File.ReadAllBytes(@"C:\SampleData.csv"); 

        string url = "http://localhost/upload.xml";
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.Method = "POST";
        request.ContentType = "multipart/form-data";
        request.ContentLength = fileToSend.Length;


        using (Stream requestStream = request.GetRequestStream())
        {
            // Send the file as body request. 
            requestStream.Write(fileToSend, 0, fileToSend.Length);
            requestStream.Close();
        } …
Run Code Online (Sandbox Code Playgroud)

c# rest wcf web-services fiddler

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×1

fiddler ×1

forms ×1

gwt ×1

html ×1

rest ×1

wcf ×1

web-services ×1