HelloWorld1
HelloWorld1

Reputation: 14108

Correct Syntax for Webapi

Goal:
The url should be "https://localhost:44353/api/Authentication/Validate?a=aa&b=bb"

Problem:
What syntax code am I missing in relation to web api?

Thank you!

// https://localhost:44353/api/Authentication/Validate/c/c
[HttpGet("Validate/{a}/{b}")]
public bool Validate(string a, string b)
{
    return false;
}

enter image description here

Upvotes: 0

Views: 58

Answers (1)

Joel Oughton
Joel Oughton

Reputation: 486

Query parameters don't need to be specified in the route pattern. The following should be enough to achieve the goal URL:

[HttpGet("Validate")]
public IActionResult Validate(string a, string b)
{
    return Ok(false);
}

Upvotes: 2

Related Questions