• <legend id='McehH'><style id='McehH'><dir id='McehH'><q id='McehH'></q></dir></style></legend>
        <tfoot id='McehH'></tfoot>

        <i id='McehH'><tr id='McehH'><dt id='McehH'><q id='McehH'><span id='McehH'><b id='McehH'><form id='McehH'><ins id='McehH'></ins><ul id='McehH'></ul><sub id='McehH'></sub></form><legend id='McehH'></legend><bdo id='McehH'><pre id='McehH'><center id='McehH'></center></pre></bdo></b><th id='McehH'></th></span></q></dt></tr></i><div id='McehH'><tfoot id='McehH'></tfoot><dl id='McehH'><fieldset id='McehH'></fieldset></dl></div>
        • <bdo id='McehH'></bdo><ul id='McehH'></ul>
      1. <small id='McehH'></small><noframes id='McehH'>

      2. Azure 函数 - 如何读取表单数据

        Azure functions - How to read form data(Azure 函数 - 如何读取表单数据)
              <tbody id='4mKWw'></tbody>
            <tfoot id='4mKWw'></tfoot>

            <i id='4mKWw'><tr id='4mKWw'><dt id='4mKWw'><q id='4mKWw'><span id='4mKWw'><b id='4mKWw'><form id='4mKWw'><ins id='4mKWw'></ins><ul id='4mKWw'></ul><sub id='4mKWw'></sub></form><legend id='4mKWw'></legend><bdo id='4mKWw'><pre id='4mKWw'><center id='4mKWw'></center></pre></bdo></b><th id='4mKWw'></th></span></q></dt></tr></i><div id='4mKWw'><tfoot id='4mKWw'></tfoot><dl id='4mKWw'><fieldset id='4mKWw'></fieldset></dl></div>

            <small id='4mKWw'></small><noframes id='4mKWw'>

              <bdo id='4mKWw'></bdo><ul id='4mKWw'></ul>
            • <legend id='4mKWw'><style id='4mKWw'><dir id='4mKWw'><q id='4mKWw'></q></dir></style></legend>

                1. 本文介绍了Azure 函数 - 如何读取表单数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何在Azure函数中读取表单数据?我尝试了几种方法,但总是出现错误,例如:

                  How to read form data in Azure functions? I tried to do it in several ways, but always I get an error, eg.:

                  using System.Net;
                  
                  public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
                  {
                      dynamic data = await req.Content.ReadAsFormDataAsync();
                  
                      return req.CreateResponse(HttpStatusCode.OK, $" {data}");
                  }
                  

                  错误:执行函数时出现异常:Functions.FormTrigger.System.Net.Http.Formatting:没有 MediaTypeFormatter 可用于从媒体类型为application/json"的内容中读取FormDataCollection"类型的对象.

                  我检查了请求内容,我收到的请求是 multipart/form-data:

                  I checked request content and I'm getting request as multipart/form-data:

                  " ------WebKitFormBoundary47wKq7pk9Fcc4H9J
                  Content-Disposition: form-data; name="name"
                  
                  sdgs
                  
                  ------WebKitFormBoundary47wKq7pk9Fcc4H9J
                  Content-Disposition: form-data; name=" _replyto"
                  
                  sdg@sdg.com
                  
                  ------WebKitFormBoundary47wKq7pk9Fcc4H9J
                  Content-Disposition: form-data; name="message"
                  
                  sdgsd
                  
                  ------WebKitFormBoundary47wKq7pk9Fcc4H9J--
                  "
                  

                  感谢您的任何提示.

                  推荐答案

                  由于请求包含application/x-www-form-urlencoded"类型的内容,需要将输入转换为NameValueCollection才能读取输入:

                  As the request contains "application/x-www-form-urlencoded" type of contents, you need to convert the input to NameValueCollection in order to read input:

                  NameValueCollection col = req.Content.ReadAsFormDataAsync().Result; 
                  return req.CreateResponse(HttpStatusCode.OK, $" {col[0]}");
                  

                  您还可以传递 Key 字符串而不是 Index,这将使代码更具可读性和不言自明

                  You can also pass Key string instead of Index which would make the code more readable and self-explanatory

                  这篇关于Azure 函数 - 如何读取表单数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding and removing users from Active Directory groups in .NET(在 .NET 中的 Active Directory 组中添加和删除用户)
                  set equality in linq(在 linq 中设置相等)
                  HashSet conversion to List(HashSet 转换为 List)
                  How to set timeout for webBrowser navigate event(如何为 webBrowser 导航事件设置超时)
                  Test whether two IEnumerablelt;Tgt; have the same values with the same frequencies(测试两个IEnumerablelt;Tgt;具有相同频率的相同值)
                  How do you determine if two HashSets are equal (by value, not by reference)?(您如何确定两个 HashSet 是否相等(按值,而不是按引用)?)
                2. <tfoot id='8PF1q'></tfoot>
                  <legend id='8PF1q'><style id='8PF1q'><dir id='8PF1q'><q id='8PF1q'></q></dir></style></legend>

                    <bdo id='8PF1q'></bdo><ul id='8PF1q'></ul>
                    • <small id='8PF1q'></small><noframes id='8PF1q'>

                            <tbody id='8PF1q'></tbody>
                          <i id='8PF1q'><tr id='8PF1q'><dt id='8PF1q'><q id='8PF1q'><span id='8PF1q'><b id='8PF1q'><form id='8PF1q'><ins id='8PF1q'></ins><ul id='8PF1q'></ul><sub id='8PF1q'></sub></form><legend id='8PF1q'></legend><bdo id='8PF1q'><pre id='8PF1q'><center id='8PF1q'></center></pre></bdo></b><th id='8PF1q'></th></span></q></dt></tr></i><div id='8PF1q'><tfoot id='8PF1q'></tfoot><dl id='8PF1q'><fieldset id='8PF1q'></fieldset></dl></div>