Click here to Skip to main content
15,921,295 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i am just learning web Apis in ASP.Net ... I getting the hang of it so far and my mini projects are working well. I was just wondering if someone would explain to me why we have to declare
C#
[ResponseType(typeof(myTable))] 
above every IHttpAction result? and also what that does.

Thank you.
Posted
Comments
ZurdoDev 16-Dec-15 8:49am    
I haven't used IHttpAction but being that the property is ResponseType it likely is declaring what return type the method will provide.

1 solution

Use this to specify the entity type returned by an action when the declared return type is HttpResponseMessage or IHttpActionResult. The ResponseType will be read by ApiExplorer when generating ApiDescription.

https://msdn.microsoft.com/en-us/library/system.web.http.description.responsetypeattribute(v=vs.118).aspx[^]

So the reason is to tell the user(consumer) what they can expect from you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900