Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

What is the meaning of ResponseType attribute with web api action

$
0
0

just visit the link http://www.c-sharpcorner.com/UploadFile/4b0136/Asp-Net-web-api-using-entity-framework-6-day-1/

i saw they use task for every action and they use [ResponseType(typeof(CollegeDetail))] why ?

// POST: api/CollegeDetails  
        [ResponseType(typeof(CollegeDetail))]  
        public async Task<IHttpActionResult> PostCollegeDetail(CollegeDetail collegeDetail)  
        {  
            if (!ModelState.IsValid)  
            {  
                return BadRequest(ModelState);  
            }  
            db.CollegeDetails.Add(collegeDetail);  
            await db.SaveChangesAsync();  
            return CreatedAtRoute("DefaultApi", new { id = collegeDetail.CollegeID }, collegeDetail);  
        }   

what is the meaning of [ResponseType(typeof(CollegeDetail))] attribute usage ?

when one should use [ResponseType(typeof(CollegeDetail))] attribute ?

ResponseType attribute is only used when action type is async ?

please guide me. thanks


Viewing all articles
Browse latest Browse all 4850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>