c# - Change Error response in web API -


i'm using token based authentication in web api application. in login request, if user enter wrong credentials, return response error in format.

in grantresourceownercredentials method

if (user == null)     {       context.seterror("the email or password incorrect.");       return;     } 

which return response as

 {       "error": "invalidlogin",       "error_description": "the email or password incorrect."     } 

and in application error response returned in format

{   "message": "some internal server error occurred." } 

so how can change error response of web api

    {       "message": "the email or password incorrect."     } 

edited : try this

string jsonstring = "{\"message\": \"the email or password incorrect.\"}"; context.seterror(new string(' ',jsonstring.length-12));  context.response.statuscode = 400; context.response.write(jsonstring); 

Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -