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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -