Set custom method names in ASP.Net Web API

nauna
 
on Jan 24, 2021 10:35 PM
684 Views

How to call method name instead of local api url

i have this javascript function which calls the method inside the api thru url

function refreshBracket(guid) {
    console.log(guid);
    $.get("https://localhost:44369/api/Bracket/" + guid, (response)=>testFunction(JSON.parse(response.teams), JSON.parse(response.results), guid));
}

 method inside the controller

public IHttpActionResult Get(string id)
{
    Debug.WriteLine(id);
    DataSet ds = DBAccess.ExecuteQuery("select * from abc where guid='" + id + "'");
    return Ok(new 
    {
        teams = ds.Tables[0].Rows[0]["Teams"],
         results=ds.Tables[0].Rows[0]["Results"]
    });
}

what i want is instead of this static url, i can directly call the method name https://localhost:44369/api/Bracket/

can we call the function like this web method

Call (Consume) Web Service (ASMX) in HTML Page using Plain JavaScript in ASP.Net

Download FREE API for Word, Excel and PDF in ASP.Net: Download