Visual studio: 2019 .NET Core: 2.2 Language: C#
Issue: I have created .NET Core API with GET endpoint decorated by attribute routing which accepts string parameter and here I am getting 404.7 response for some keywords e.g. ".master", ".cs", ".mdf" etc.
Not Working code:
Accessing path: http://baseUrl/api/test/test.master
[HttpGet("{userName}")]
public ActionResult<string> Get(string userName)
{
return userName;
}
Working code:
Accepting userName as a query string is working perfectly. Is it best practice?
Accessing path: http://baseUrl/api/test?userName=test.master
[HttpGet]
public ActionResult<string> Get(string userName)
{
return userName;
}
I know that these are the file extensions which are not allowed to access as resources. But is there any other way to make it work other than accepting a parameter as a query string. Can I make it work with attribute routing?
I tried to repro this issue in .NET Framework as well and its failing with the same error.