Manipulating Data in ASP.NET MVC

ASP.NET MVC applications provide interesting possibilities to accept input and work with database data. See how you can do this effectively in your work.

ASP.NET MVC is an interesting new technology that supports separating the user interface from the application logic, and the data storage from the data manipulation. When you create ASP.NET MVC applications, the old ASP.NET style of accepting input from the user is no longer the best option. Furthermore, you will also need to learn how to dynamically accept input from the user.

Assume you want to implement a method to process an URL, such as "/products/edit/NNN", where NNN would be an ID number of a product. As you learned in my earlier article, "ASP.NET MVC 101," you would start by writing a public method named Edit in the ProductsController class of your application.

However, how would you be able to retrieve the product ID that the user wants to edit? In regular ASP.NET, you would access the Request object and find the information you want. But in ASP.NET MVC, you have an surprisingly easy alternative. All you need to do is declare the Edit method so that it accepts a parameter with the name "Id", and you are done!

You might wonder how this works. To find the answer, you need to recall the declaration of the default route you saw earlier. Remember how it contained the ID parameter as the third parameter? If you declare a controller method with this parameter, you will automatically get the value as a parameter to your controller when the user accesses the URL.

The routing system in MVC applications looks for particular controller methods that have parameters that match the route parameters. The default route is "{controller}/{action}/{id}", and given the request URL of "/products/edit/123", the system looks for an Edit method that takes parameter with the name "ID" (case is not important). That is, the naming of parameters is important, but so is also typing.

Read the Rest of this Article at Developer.com

Related Articles
- Service Oriented Architecture
Can Mule help you carry the weight of your infrastructure? We'll shine a light on this open source ESB and show you how it can help you reduce complexity in your web service applications.
- ASP.NET MVC 101
- Highly Effective Datacenters
- Introduction to Multi-Tenant Architecture
- Java Hashed Collections
Regional Articles
- Manipulating Data in ASP.NET MVC Alabama
- Manipulating Data in ASP.NET MVC Alaska
- Manipulating Data in ASP.NET MVC Arizona
- Manipulating Data in ASP.NET MVC Arkansas
- Manipulating Data in ASP.NET MVC California
- Manipulating Data in ASP.NET MVC Colorado
- Manipulating Data in ASP.NET MVC Connecticut
- Manipulating Data in ASP.NET MVC DC
- Manipulating Data in ASP.NET MVC Delaware
- Manipulating Data in ASP.NET MVC Florida
- Manipulating Data in ASP.NET MVC Georgia
- Manipulating Data in ASP.NET MVC Hawaii
- Manipulating Data in ASP.NET MVC Idaho
- Manipulating Data in ASP.NET MVC Illinois
- Manipulating Data in ASP.NET MVC Indiana
- Manipulating Data in ASP.NET MVC Iowa
- Manipulating Data in ASP.NET MVC Kansas
- Manipulating Data in ASP.NET MVC Kentucky
- Manipulating Data in ASP.NET MVC Louisiana
- Manipulating Data in ASP.NET MVC Maine
- Manipulating Data in ASP.NET MVC Maryland
- Manipulating Data in ASP.NET MVC Massachusetts
- Manipulating Data in ASP.NET MVC Michigan
- Manipulating Data in ASP.NET MVC Minnesota
- Manipulating Data in ASP.NET MVC Mississippi
- Manipulating Data in ASP.NET MVC Missouri
- Manipulating Data in ASP.NET MVC Montana
- Manipulating Data in ASP.NET MVC Nebraska
- Manipulating Data in ASP.NET MVC Nevada
- Manipulating Data in ASP.NET MVC New Hampshire
- Manipulating Data in ASP.NET MVC New Jersey
- Manipulating Data in ASP.NET MVC New Mexico
- Manipulating Data in ASP.NET MVC New York
- Manipulating Data in ASP.NET MVC North Carolina
- Manipulating Data in ASP.NET MVC North Dakota
- Manipulating Data in ASP.NET MVC Ohio
- Manipulating Data in ASP.NET MVC Oklahoma
- Manipulating Data in ASP.NET MVC Oregon
- Manipulating Data in ASP.NET MVC Pennsylvania
- Manipulating Data in ASP.NET MVC Rhode Island
- Manipulating Data in ASP.NET MVC South Carolina
- Manipulating Data in ASP.NET MVC South Dakota
- Manipulating Data in ASP.NET MVC Tennessee
- Manipulating Data in ASP.NET MVC Texas
- Manipulating Data in ASP.NET MVC Utah
- Manipulating Data in ASP.NET MVC Vermont
- Manipulating Data in ASP.NET MVC Virginia
- Manipulating Data in ASP.NET MVC Washington
- Manipulating Data in ASP.NET MVC West Virginia
- Manipulating Data in ASP.NET MVC Wisconsin
- Manipulating Data in ASP.NET MVC Wyoming
Related Articles
- Service Oriented Architecture
Can Mule help you carry the weight of your infrastructure? We'll shine a light on this open source ESB and show you how it can help you reduce complexity in your web service applications.
- ASP.NET MVC 101
- Highly Effective Datacenters
- Introduction to Multi-Tenant Architecture
- Java Hashed Collections

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML