dotnet core + (plus) sign in Web API 路由 [英] Dotnet core + (plus) sign in Web API routing

查看:43
本文介绍了dotnet core + (plus) sign in 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 问题:

This is an IIS issue:

请看以下帖子:

双转义序列在一个url : 请求过滤模块配置为拒绝包含双转义序列的请求

如果您尝试使用 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 core + (plus) sign in Web API 路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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