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));
}
}
Request URL:
http://localhost:3364/api/user/mobile/exist/+123456
When I request above URL with the plus sign it given an error.
The Same URL without + sign it's working good.
I try with encoded + sign with %2B but it not working
How can I request with plus sign?
Inside the ConfigureRoute method, you can configure your routes; you can see that this method has to take a parameter of type IRouteBuilder. The goal of routing is to describe the rules that ASP.NET Core MVC will use to process an HTTP request and find a controller that can respond to that request.
Web API 2 supports a new type of routing, called attribute routing. As the name implies, attribute routing uses attributes to define routes.
Routing in ASP.NET Core Web API application is the process of mapping the incoming HTTP Request (URL) to a particular resource i.e. controller action method. For the Routing Concept in ASP.NET Core Web API, we generally set some URLs for each resource.
This is an IIS issue:
Please look at the following post:
double escape sequence inside a url : The request filtering module is configured to deny a request that contains a double escape sequence
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With