我正在处理一个 asp.net web api 项目,我必须通过一个帖子传递一个手机号码。但是我不能返回加号。
我的路线:
config.Routes.MapHttpRoute(
name: "SmsRoute",
routeTemplate: "rest/sms/{country}/{company}/phone/{mobilenumber}",
defaults: new { controller = "Sms", action = "PostSms" });
Controller :
public HttpResponseMessage PostSms(string country, string company, string mobilenumber)
{
return Request.CreateResponse( HttpStatusCode.Created );
}
当我在 fiddler 上运行这个 post 方法时:
http://index.html/rest/sms/se/company/phone/46700101010/messages/out
我收到这样的回复:
但我希望它能够显示加号。
最佳答案
IIS 阻止加号出现在 URL 路径元素中。
要禁用此功能,请在 web.config
中:
<system.webServer>
<security>
<requestFiltering allowDoubleEscaping="true" />
</security>
</system.webServer>
关于c# - +(加号)登录 Web API 路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26120919/