Web Development Essentials: ASP.NET MVC Introduction & API Consumption

Slide Note
Embed
Share

Learn the fundamentals of web development with ASP.NET MVC and explore how to consume web API services using jQuery and C# code. Discover the MVC design pattern, routing, model creation, and more in this comprehensive guide.


Uploaded on Oct 09, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. CREATING A WEBSITE [758-761] & INTRODUCTION TO ASP.NET MVC[763- 775] Peruri, Soumya PID:11 Thadikamalla, Tribhuvan Datta PID: 18 Karnati, Bhavya PID:16 Siddharth Lucky PID:23 Upadyayula, SubrahmanyaYasho vardhan PID: 09

  2. CONTENTS: How to consume a web API service using Jquery How to consume a web service using C# code The MVC design pattern Shopping cart as an MVC application Introduction to ASP.NET MVC Files and folders for a new MVC application Razor view engine and syntax How to work with routing How to create a model

  3. HOW TO CONSUME A WEB API SERVICE USING JQUERY Most of the time, we will want to use jQuery to consume a Web API service. That s because we can make asynchronous Ajax requests with jQuery ,which can improve response time. To illustrate the use of jQuery, code presents some of the JavaScript and jQuery code that s in the webapi.js file for the website that consume the web API service. The JavaScript code is loaded automatically when the page is requested by a browser, it runs in the browser without server calls, and it can respond to user events like checking the links.

  4. DESCRIPTION When we use jQuery to consume a web API service, Ajax is used to get and update the data with asynchronous requests. This is generally considered to be the best way to consume web API service. This again shows how important JavaScript and jQuery are to the web developer .To learn more about how this page works, we can use Murach s JavaScript and jQuery.

  5. HOW TO CONSUME A WEB API SERVICE USING C# CODE We just learned, we will usually want to use jQuery to consume web API service because jQuery can make asynchronous Ajax requests from the browser. However, we can also consume a web API service synchronously using C# code. In given code we can see a web page that uses a GridView control and a C# code behind file to display the category data that s returned by the categories wed service. When a web site consumes a web API service, the data can be returned as JSON or XML data. Although there are native and third- party .NET classes for working with JSON, the .NET XML classes and the LINQ to XML functionality make XML a good choice when we are using C# code to consume a service

  6. CHAPTER 24 An Introduction to ASP.NET MVC

  7. INTRODUCTION TO MVC(MODEL VIEW CONTROLLER) In recent years, ASP.NET MVC is more famous as a web development tool. ASP.NET facilitates unit testing, uses naming and structure conventions for configurations and works directly with HTTP requests. Web forms are typically used for intranet web applications and websites that need to use state or complex server. MVC is typically used for websites with high traffic and a need for search engine optimization and good performance.

  8. THE MVC DESIGN PATTERN Web Forms application often combine code that accesses database with HTML code, as with SqlDatasource controls. Also, the code-behind files in Web Forms application are tightly coupled with their aspx files, which makes it hard for one person to work on an aspx file while another works on this code-behind file. The MVC pattern works by breaking an application into component parts. Its important to note that each component should stick to its own area of concern and be as independent as possible. For example, the model should retrieve and validate data but it shouldn t have anything to do with displaying it. Similarly, the controller should move data between the model and the view but it shouldn t apply any business rules to it.

  9. THE MVC DESIGN PATTERN

  10. MVC COMPONENTS The model consists of the files that contain data access code, business logic code and data validation code. The view consists of files that create the HTML for the user interface and return a response to the user. The controller consists of the files that receive requests from the user, get the appropriate data from the model, and provide that data to the view. The view model is an optional component that consists of files whose only job is to transfer data from the controller to the view.

  11. PROCEDURE TO CREATE MVC APPLICATION

  12. THE SHOPPING CART AS AN MVC APPLICATION This will introduce you to the basic ASP.NET MVC concepts and skills by showing examples from an MVC Version of shopping cart application. First you create a application itself then you add a model, after your model is in place you use it to create a controller, after your controller is in place you create a view.

  13. THE SHOPPING CART AS AN MVC APPLICATION

  14. PAGES IN CART APPLICATION AND THE CONCEPTS

  15. THE BENEFITS OF MVC The MVC structure leads to better separation of concerns. For instance, the designers can work with the views and the developers can work with the controllers. MVC works with the stateless nature of the web. This means that there s less overhead trying to replicate state, which can also improve performance. Easier to code, test and maintain. Improves page performance.

  16. PAGES IN CART APPLICATION AND THE CONCEPTS

  17. INTRODUCTION TO ASP.NET MVC ASP.NET MVC Application is built on ASP.NET, many objects that have been worked in web forms such as session state object and response object are also available in MVC. But how an MVC application is organized and how it handles http requests is completely different.

  18. DIALOGUE BOX FOR STARTING AN ASP.NET MVC APPLICATION

  19. FILES AND FOLDERS FOR A NEW MVC APPLICATION Though the number of files and folders seem to be overwhelming at first ,it is broken into components there needs to be separate files and folders for these components. Most of the time we will work with the folders containing models, views,controllers,scripts,and styles

  20. MAIN FOLDERS AND FILES

  21. RAZOR VIEW ENGINE AND SYNTAX When working with dynamic web application, we need some way to combine dynamic data with the static html of the page and render it all to the browser. ASP.NET Web forms application use the ASPX view engine. This engine uses HTML, server controls and inline data binding. Microsoft came out with Razor view engine which has a simpler data binding syntax.

  22. HOW TO WORK WITH ROUTING The first line of the RegisterRoutes method of the RouteConfig.cs file. This is located in the App_Start folder and it is created by default when you start a new ASP.NET web application. The default parameter sets default values for the route. The method has three parameters and the name parameter simply names the route.

  23. RAZOR SYNTAX EXAMPLES

  24. HOW TO CREATE A MODEL A Model contains the code that deals with the data It contains data access folder that contains an Entity Data Model that was created by using the entity framework, although the data access methods could have been created by regular c#. Model for an application has three main tasks first it gets up and updates second it apllies business rules to the data third it applies validation rules to the data.

  25. MODELS SUBDIRECTORY

  26. CART MODEL AND CART VIEW MODEL

  27. THANK YOU

Related