简体   繁体   中英

parameterized routing not accepting the dot as parameter in web api routing

I am using the parameterized routing for my web api calling. it is working fine for all special characters other than dot. code which I tried

 [HttpGet]
    [Route(@"TestMethod/{strvalue:regex((?s).*)}")]
 public IHttpActionResult TestMethod(string strvalue)
    {
        try
        {
           // logic
        }
        catch (Exception ex)
        {
            return Content(HttpStatusCode.BadRequest, "Error details:" + ex.Message);
        }
    }

when I pass the parameter value dot(.) it is not accepting the request. getting the response as

 Request URL
 http://localhost:64515/TestMethod/.

 Response: 
 {
"Message": "The requested resource does not support http method 'GET'."
}

Expected result: even if i pass any charactor like #,.%$@#&* that request should be accept

Following code in your web.config should fix your issue:

<configuration>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM