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

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

问题描述

我在dotnet核心中的Web API项目上工作,并检查用户手机号是否存在。

I work on web API project in the dotnet core and check user mobile number exists check.

[Route("api/[controller]")]
public class UserController : Controller
{
    [HttpGet]
    [Route("mobile/exist/{mobile}/{id:int?}")]
    public async Task<IActionResult> MobileExist(string mobile, int? id)
    {
        return Json(await _userService.MobileExist(mobile, id));
    }
}

请求网址:


http:// localhost: 3364 / api / user / mobile / exist / + 123456

当我在上方请求带有加号的URL时错误。

When I request above URL with the plus sign it given an error.

不带+号的相同URL很好用。

The Same URL without + sign it's working good.

我尝试使用编码的 + %2B 签名,但不起作用

I try with encoded + sign with %2B but it not working

如何请求加号?

推荐答案

这是一个IIS问题:

请查看以下帖子:

double escape sequence inside a url : The request filtering module is configured to deny a request that contains a double escape sequence

如果尝试使用Kestrel运行应用程序,您将看到它可以正常工作。
对于IIS,您需要在web.config中添加以下部分:

If you try to run your app with Kestrel, you will see that it works. For IIS, you will need to add the following section in you web.config:

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

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

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