首页 > 解决方案 > 如何在 WCF 中获取 POST 请求数据?

问题描述

我有一个离子应用程序,我需要通过 wcf 服务将一个大字符串插入到数据库中。我在 POST 请求的正文中发送字符串。

我的角度方法看起来像这样 -

      uploadPic(bugImage : any)
        {    
    this.http.post("http://192.168.123.162/MyRestService/MyRestService.svc/ReportaBug", bugImage).subscribe(
            (data:any) => {
            console.log(data);
     }
   )
}

当我将请求检查到 chrome 的开发人员工具>网络时,请求的状态是好的,但是当我检查数据库时,插入的字符串是空白的。

这是我的服务代码-

 [OperationContract]
        [WebInvoke(Method ="POST", UriTemplate = "/ReportaBug/base64String={base64String}", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json )]
        void ReportaBug(string base64String);

如何从 WCF 中的正文中获取数据?无论我从我的角度代码发送什么字符串,似乎都没有被服务捕获。它只是将空白字符串插入数据库。我如何让这个工作?

标签: c#angularwcfionic-framework

解决方案


推荐阅读