Join Kazi Nasrat Ali for an in-depth discussion in this video Add an action method to read records in JSON format, part of Building React and ASP.NET MVC 5 Applications.
- [Instructor] In this video, I'm going to write some code…into GetMenuList function, and GetUserID function.…For GetMenuList, I want to return the food items…in json format.…First I'm going to declare a variable,…it's going to hold the food items,…so it's going to be a list, public, IList, Food Item.…This is in namespace models, so add that,…and let's call this variable menulist,…menuItems.…
So, let's initialize menuItems first.…New list, food item, we're going to use the db again,…so let's declare and initialize,…var db equals new AppDbContext.…Here, I'm going to redirect through the food items,…and add to menu items, list.…So for each var f in db.FoodItems,…and add this to menuItems.…
So now at the end of this loop,…I have all the menu items in the list.…I want to now return as a json data.…So return, let's delete the first, return,…so now, return,…json,…menuItems,…and we want to allow get, so json behavior,…json request behavior dot allow get,…so my function is now coded,…let's build it and test this.…
We've succeeded, now let's run it in debug mode.…
Author
Released
11/27/2018- Creating the back end
- Scaffolding a project with MVC 5
- Setting up the service API for data
- Creating the front end with React
- Handling events for React elements
- Responsive UI and mobile friendliness
- Securing the API
- Debugging the front end and back end
Skill Level Intermediate
Duration
Views
Related Courses
-
ASP.NET MVC: HTTP Request Life Cycle
with Janan Siam2h 15m Intermediate
-
Introduction
-
1. About ASP.NET MVC 5 and React
-
2. Create the Back End
-
Add register and login views3m 55s
-
3. Setup: A Service API for Data
-
Create a REST API controller3m 33s
-
-
4. Setup: TypeScript, IntelliSense, and webpack
-
5. Create the Front End with React
-
6. Secure the API
-
7. Debugging and Testing
-
Testing and completion8m 3s
-
Conclusion
-
Next steps43s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Add an action method to read records in JSON format