Logo

Maarten Balliauw {blog}

ASP.NET, ASP.NET MVC, Windows Azure, PHP, ...

About the author

Maarten Balliauw is currently employed as a Technical Evangelist at JetBrains. His interests are mainly web applications developed in ASP.NET (C#) or PHP and the Windows Azure cloud platform.
More about me More about me
Send mail E-mail me


ASP.NET MVC Quickly Pro NuGet Subscribe to my RSS feed Follow me on Twitter! View Maarten Balliauw's profile on LinkedIn
Maarten Balliauw - MVP - Most Valuable Professional
Maarten Balliauw - ASPInsider

Search

Archive

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright Maarten Balliauw 2013


Sample chapter from ASP.NET MVC 1.0 Quickly

image Here’s a shameless, commercial blogpost… With yesterday’s 1.0 release of the ASP.NET MVC framework, I’m sure the following sample chapter from my book ASP.NET MVC 1.0 Quickly will be of use for people starting ASP.NET MVC development: Your first ASP.NET MVC application.

When downloading and installing the ASP.NET MVC framework SDK, a new project template is installed in Visual Studio. This chapter describes how to use the ASP.NET MVC project template that is installed in Visual Studio. All ASP.NET MVC aspects are touched briefly by creating a new ASP.NET MVC web application based on this Visual Studio template. Besides view, controller, and model, new concepts including ViewData—a means of transferring data between controller and view, routing—the link between a web browser URL and a specific action method inside a controller, and unit testing of a controller are also illustrated here.

In this chapter, you will:

  • Have an overview of all the aspects of an ASP.NET MVC web application
  • Explore the ASP.NET MVC web application project template that is installed in Visual Studio 2008
  • Create a first action method and corresponding view
  • Create a strong-typed view
  • Learn how a controller action method can pass strong-typed ViewData to the view
  • Learn what unit testing is all about, and why it should be used
  • Learn how to create a unit test for an action method by using Visual Studio's unit test generation wizard and modifying the unit test code by hand

Download the free sample chapter here. Or order the full book, here. That’s a better option ;-)

By the way, if you are interested in the book writing process itself, check my previous blog post on that.

kick it on DotNetKicks.com


Categories: ASP.NET | Books | C# | General | MVC | Personal | Publications

Comments (6) -

Bill Beckelman United States |

Thursday, March 19, 2009 3:01 PM

Bill Beckelman

Maarten,

I purchased the book yesterday and look forward to digging into it over the weekend.

Bill

maartenba Belgium |

Thursday, March 19, 2009 3:03 PM

maartenba

Cool, thanks! Do let me know if you have any comments on it.

Vladimir Kelman United States |

Sunday, April 12, 2009 10:57 AM

Vladimir Kelman

Hello!
I'd like to apologize for novice and possible stupid question... I started to read your book and to play with examples and run Chapter 3 / Updating Data Example. Its Index.aspx View uses Html.ActionLink() methods to produce links, like
<%=Html.ActionLink("Request variables", "Edit", new { id = 0, postAction = "RequestVariables", formName = "HelperForm" })%>
When I run application this renders the following link:
http://localhost:2438/Home/Edit/0?postAction=RequestVariables&formName=HelperForm

MSDN says (msdn.microsoft.com/en-us/library/dd492936.aspx) about last parameter of ActionLink() method:
routeValues: "An object that contains the parameters for a route..."

So, how does ActionLink() know to render "id" parameter differently from "postAction" and "formName" parameters?
I see that "id" becomes a part of URL which corresponds to {id} part of the route, while "postAction" and "formName" become part of query string.  Is "id" some kind of magic string?
I tried to replace "id" with "id1" on Index.aspx which immediately leads to producing UR like
http://localhost:2438/Home/Edit/?id1=0&postAction=RequestVariables&formName=HelperForm

maartenba Belgium |

Tuesday, April 14, 2009 8:19 AM

maartenba

Hello Vladimir,

The routing engine actually "sees" that there is a route that expects the id parameter. ActionLink() uses the route dictionary to determine the URL, which will thus be generated using the id parameter from the route. Parameters that are not in the route are appended as a query string.

Regards,
Maarten

Vladimir Kelman United States |

Tuesday, May 12, 2009 4:57 AM

Vladimir Kelman

Got it, thank you. I replaced id to id1 in global.aspx.cs for a moment, and index.aspx immediately started to render id as a query string, since id was no more in the route.

Maarten, is there something like a forum (perhaps a Google Group) for readers of your book? I don't really want to bother you with questions, on which many readers, more knowledgeable than me, could answer. And... it just helps to have a group of people who share similar learning goal. I know it well by "Authors forums" for Manning books.

maartenba Belgium |

Tuesday, May 12, 2009 8:11 AM

maartenba

Only thing I am aware of is this one: www.packtpub.com/.../asp-net-model-view-controller-1-0-quickly

Pingbacks and trackbacks (5)+

Comments are closed