I have this update method in controller, and this url works: http://localhost:5000/Ad/update/id/1/isActive/false
Is there a way I can make the url include question mark and parameters so that it'll be on this form:
http://localhost:5000/Ad/update?id=2&newStatus=false
[HttpPut("update/id/{id:int}/isActive/{newStatus:bool}")]
public async Task<ActionResult> Update(int id, bool newStatus)
{
some code.....
}
CodePudding user response:
The parameters that come after the ?
are the same ones you pass as a part of the URL. Meaning if you say {id:int}
, I can type the same thing as ?id=123
as a part of the URL. It's just a way to format the URL to an SEO and human-friendly format. So no, there's no way you could be able to control what is passed to you. You can, however, validate the inputs that are passed to your action.