@Ying Kit Li , Azure definitely supports restful services. I would suggest enabling application logging so you can see what exactly is causing your 405 error. Another place to check is the Diagnose and solve problems blade.
Having said that, a 405 error usually means method not allowed, therefore, I would make sure the client is calling UpdatePassword method route with HTTP PUT verb. I would also wrap passwordReturn
in an OkObjectResult
and wrap the .FromSqlRaw
command in a try catch so BadRequest
could be returned in case the stored procedure failed to execute.
EDIT:
Azure doesn't restrict how your app responds to request, you control that. In your code snippet:
[Route("{Contact_No}/{Password}")]
[HttpPut]
public ActionResult<List<passwordDTO>> UpdatePassword(string Contact_No, String Password)
[HttpPut]
will mean your <yourapp>.azurewebsites.net/{Contact_No}/{Password} will only respond to HTTP PUT request. If you want this method to also respond to GET
s, then decorate your method by adding [HttpGet]
as well. You can also use [AcceptVerbs()]
as you previously discovered.
So your method could easily be
[Route("{Contact_No}/{Password}")]
[HttpGet]
[HttpPut]
public ActionResult<List<passwordDTO>> UpdatePassword(string Contact_No, String Password)
It is one and the same as doing
[Route("{Contact_No}/{Password}")]
[HttpPut]
[AcceptVerbs("GET")]
public ActionResult<List<passwordDTO>> UpdatePassword(string Contact_No, String Password)
If dbo.uspPasswordSalt
isn't really doing any data updates and is simply retrieving data, then I would recommend removing [HttpPut]
attribute as PUT infers the API method will insert (or update) that resource.
See https://learn.microsoft.com/en-us/aspnet/web-api/overview/web-api-routing-and-actions/routing-in-aspnet-web-api#routing-variations for more information.