asp.net-web-api - 如何将带空格的参数发送到 .net web api

标签 asp.net-web-api

我想在我的 Web api 中的方法中收到一个包含空格的长字符串

据我了解,我无法发送带有空格的参数,是否必须以某种方式对其进行编码?

编辑:

我的内容类型是:

Content-Type: application/x-www-form-urlencoded 

我已将其更改为其他几种类型,但它们都不允许我接收带有 + 而不是空格的参数

我的帖子方法签名是

public HttpResponseMessage EditCommentForExtension(string did, string extention, string comment)

最佳答案

通常,HTTP GET 请求的参数为 URL encoded 。这意味着(除其他外)空格被“+”替换。

关于asp.net-web-api - 如何将带空格的参数发送到 .net web api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16209359/

相关文章:

c# - 单元测试中的 ActionResult 问题无法断言。POST 返回值等于(asp.net core mvc web api)

c# - WCF 和 Web API 的区别总结

asp.net-mvc - 使用 Swashbuckle 托管现有的 Swagger.JSON 文件

c# - 有选择地使用默认的 JSON 转换器

c# - 测试网络 API 服务

c# - Web API - 从模型返回一些字段

c# - 无法从 Web API 中的删除方法获取参数

asp.net-mvc - ASP.NET MVC Controller 无法使用流式内容正确返回 HttpResponseMessage

asp.net-web-api - 托管在 Azure 上的高可用性 Service Fabric Web Api

asp.net-mvc - 如何为 ASP.NET 4.5 Web API 创建 MultipartFormFormatter