+(加号)登录Web API路由 [英] + (plus) sign in Web API routing

查看:87
本文介绍了+(加号)登录Web API路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用asp.net Web api项目,并且必须通过帖子传递手机号码.但是我不能返回加号.

I'm working with an asp.net web api project, and I have to pass an mobile number through a post. But i cannot return a plus sign.

我的路线:

config.Routes.MapHttpRoute( 
    name: "SmsRoute",
    routeTemplate: "rest/sms/{country}/{company}/phone/{mobilenumber}",
    defaults: new { controller = "Sms", action = "PostSms" });

控制器:

public HttpResponseMessage PostSms(string country, string company, string mobilenumber)
{
    return Request.CreateResponse( HttpStatusCode.Created );
}

当我在提琴手上运行此post方法时:

When I run this post method on fiddler:

http://index.html/rest/sms/se/company/phone/46700101010/messages/out

我收到此回复:

但是我希望它能够向我显示加号.

But I want it to be able to show me the plus sign.

推荐答案

IIS阻止加号出现在URL路径元素中.

IIS prevents plus-signs from being in URL path elements.

要禁用此功能,请在web.config中:

To disable this feature, in web.config:

<system.webServer>
    <security>
        <requestFiltering allowDoubleEscaping="true" />
    </security>
</system.webServer>

这篇关于+(加号)登录Web API路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆