Generating links using route names in asp net web api
Text version of the video http://csharp-video-tutorials.blogspot.com/2017/02/generating-links-using-route-names-in.html Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help. https://www.youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?sub_confirmation=1 Slides http://csharp-video-tutorials.blogspot.com/2017/02/generating-links-using-route-names-in_21.html All ASP .NET Web API Text Articles and Slides http://csharp-video-tutorials.blogspot.com/2016/09/aspnet-web-api-tutorial-for-beginners.html All ASP .NET Web API Videos https://www.youtube.com/playlist?list=PL6n9fhu94yhW7yoUOGNOfHurUE6bpOO2b All Dot Net and SQL Server Tutorials in English https://www.youtube.com/user/kudvenkat/playlists?view=1&sort=dd All Dot Net and SQL Server Tutorials in Arabic https://www.youtube.com/c/KudvenkatArabic/playlists To generate links in ASP.NET Web API using route names 1. Set a name for the route using the Name property of the [Route] attribute [Route("{id:int}", Name = "GetStudentById")] public Student Get(int id) { return students.FirstOrDefault(s =] s.Id == id); } 2. Use the name of the route to generate the link public HttpResponseMessage Post(Student student) { students.Add(student); var response = Request.CreateResponse(HttpStatusCode.Created); response.Headers.Location = new Uri(Url.Link("GetStudentById", new { id = student.Id })); return response; }
Download
0 formatsNo download links available.