pandora
Now from NewTech: ASP.NET 3.5 Training
NewTech offers the most comprehensive and practical training in the .NET community today. Click here to learn more about our BOOTCAMP style ASP.NET 3.5 Training.

View our Student Testimonials and the Site Map here.

tiffany www.mccabecapital.com
 


Home Page
Contact Us
Online .NET Training
Register for a Class
Agile CT UserGroup
Recent .NET Training Clients
5-Day ASP.NET Training
.NET 3.5 Developer
Hands-On BOOTCAMPs
ASP.NET Training 5-day BOOTCAMP using C#.NET™
NewTech's intense hands-on ASP.NET Training with C#.NET, using the current version, in a comprehensive 5-day format.
ASP.NET Training 5-day BOOTCAMP using VB.NET™
NewTech's intense hands-on ASP.NET Training with VB.NET, using the current version, in a comprehensive 5-day format.
1-Day .NET 3.5 Training:
AJAX & LINQ
Hands-On Training
AJAX Training Hands-On
1 intense hands-on day of AJAX training in .NET
LINQ Training Hands-On
1 intense hands-on day of LINQ training under .NET
4-Day .NET Training
Windows Forms
Hands-On BOOTCAMPs
VB.NET Training BOOTCAMP™
4 Days of expert hands-on Windows Forms training using VB.NET
C# .NET 3.5 Training BOOTCAMP™
4 Days of intense hands-on Windows Forms training using C#.NET
Other Microsoft
Developer Training
We Offer:
ASP Training/ Web Development BOOTCAMP™
4 intense days of ASP training using Visual Interdev...includes JavaScript, DHTML
VB Training Intro ASAP™
VB6 Intermediate Bootcamp is going from a 4-Day BOOTCAMP-style to a single day seminar-style (ASAP) lecture.
VB Training Advanced BOOTCAMP™
The most advanced VB Training available, recently updated to include XML with DOM and SAX
Quick .NET Training for Developers
VB.NET Training ASAP™
1 intense day of essentials
ASP.NET Training ASAP™
1 day fast-forward ASP.NET
C# Training ASAP™
1 day of full immersion C#
Quick .NET Training for IT Managers
.NET vs. Java Platform Technology Overview
1 day of intense compare and contrast
.NET Training: The 1-day .NET for Managers (with some hands-on)
The 1-day seminar that completely DEMYSTIFIES .NEt technology, for MANAGERS
'ASAP' OOP Training and UML Training
UML Training ASAP™
1-day full-immersion course in UML-based Systems Design
OOP Training ASAP™
1-day full-immersion course in Object Oriented Programming Concepts
Cities Where We Delivered ONSITE .NET training recently:

Washington,DC
New York City,NY
Philadelphia ,PA
Los Angeles ,CA
Chicago ,IL
Houston ,TX
Phoenix ,AZ
Philadelphia ,PA
San Antonio ,TX
San Diego ,CA
Dallas ,TX
San Jose ,CA
Detroit,MI
Jacksonville ,FL
Indianapolis,IN
San Francisco ,CA
Austin ,TX
Memphis ,TN
Fort Worth ,TX
Baltimore,MD
Charlotte ,NC
El Paso ,TX
Milwaukee ,WI
Boston ,MA
Seattle ,WA
Washington ,DC
Denver ,CO
Louisville ,KY
Las Vegas ,NV
Nashville ,TN
Oklahoma City ,OK
Portland ,OR
Tucson ,AZ
Albuquerque ,NM
Atlanta ,GA
Long Beach ,CA
Fresno ,CA
Sacramento ,CA
Mesa ,AZ
Kansas City ,MO
Cleveland ,OH
Virginia Beach, VA
Omaha ,NE
Miami ,FL
Oakland ,CA
Tulsa ,OK
Honolulu,HI
Minneapolis ,MN
Colorado Springs ,CO
Arlington ,TX
Wichita ,KS
Raleigh ,NC
Santa Ana ,CA
Anaheim ,CA
Tampa ,FL
Cincinnati ,OH
Pittsburgh ,PA
Bakersfield ,CA
Aurora ,CO
Toledo ,OH
Riverside ,CA
Stockton ,CA
Corpus Christi ,TX
Newark ,NJ
Anchorage ,AK
Buffalo ,NY
St. Paul ,MN
Lexington ,KY
Plano ,TX
Fort Wayne ,IN
St. Petersburg ,FL
Glendale ,AZ
Jersey City ,NJ
Lincoln ,NE
Henderson ,NV
Chandler ,AZ
Norfolk,VA
Greensboro ,NC
Scottsdale ,AZ
Baton Rouge ,LA
Birmingham ,AL
Madison ,WI
New Orleans ,LA
Chesapeake ,VA
Orlando ,FL
Garland ,TX
Hialeah ,FL
Laredo ,TX
Chula Vista ,CA
Lubbock ,TX
Reno ,NV
Akron ,OH
Durham ,NC
Rochester ,NY
Modesto ,CA
Montgomery ,AL
Fremont ,CA
Shreveport ,LA
Arlington ,VA
Glendale ,CA
San Bernardino ,CA
Worcester ,MA
Providence ,RI

ASP MVC
Page 2

Enter ASP.NET

If your only experience with MVC is through a Model 2 architecture, the ability to implement an MVC architecture in ASP.NET is not immediately apparent. However, ASP not only allows MVC, it encourages it in the way the pattern was originally conceived.

Since the definition of MVC states that the View renders the data from the Model and that the Controller sends user events to the Model, generally from the elements rendered on the view, most could agree that there is a very high natural coupling between the View and the Controller. So, a natural real world implementation of MVC, and indeed what you normally find outside of web applications, is a one to one correspondence between the View and the Controller. However, in a web application, there is a need to not only send data to the model, there is also a need to control which view should render based on the data the model currently contains. A kind of a "View Controller." In some Model 2 implementations, there is a central Controller which we will call the "View Controller." This View Controller delegates form processing to other programming entities and eventually redirects to the appropriate view. JavaBeans in the case of JSP, ActiveX controls in the case of ASP. If you've ever worked with the Struts framework for JSP you are familiar with this model.

Since ASPX pages post back to themselves, we obviously can't use a "View Controller." So, how does one implement the same functionality in .NET? Furthermore, those familiar with Struts will recognize that the ability to loosely couple the views (or controllers) from each other is not available in ASP.NET "out of the box."

The following architecture solves both of these problems.

In a Model 2 architecture using a Central Controller, a delegate pattern is used to control access to the different services, or sub-controllers. You ask for a service and the central controller determines if you should be allowed access to the service and how to implement the service.

In ASP.NET, you generally ask for the service directly. Instead of a service being a sub-controller, it is the main point of entry. What this doesn't offer is a central location for determining if you should have access to the service in the first place, or, any other common processing that should happen in all of the services. However, by having all of your code-behind pages inherit from a common class that is a subclass of System.Web.UI.Page, you can place all of this pre-processing code in the OnLoad() method that you override from the Page class. OnLoad() is call by the framework every time the page is loaded. But before the Page_Load() method is called in your code-behind page. This allows you to verify that the service is allowed and do any redirecting you need to do in one central location, using Server.Transfer(), similar to what a Central Controller would do. I named my View Controller class ViewController.

The second requirement, making the views loosely coupled from each other, requires a bit more work. First, you will need to create an enum in your ViewController class that has an entry that corresponds to each page in your web application. I also added an enum named UNDEFINED. Second, you will need to create a member variable to hold the ID of the page. I initialized mine to UNDEFINED. This gets placed in your ViewController class and is of the type of your enum. Third, you will need to create a property to access this member variable. I've named mine ServiceID. Fourth, create a method in your ViewController named getServicePage() that takes the enum as a parameter and returns a string containing the appropriate aspx file. Finally, in the contructor of each of your code-behind pages, set the ServiceID of the page. Now, anywhere in your code where you are redirecting or linking to an aspx page in your application, you will call the getServicePage() method to retrieve the name of the file to redirect to.

If you've ever refactored your website to the point of renaming web pages, you should immediately see that this will significantly simplify maintenance. If you want to rename an aspx file you now can rename the file and change the lookup in getServicePage and your site should still work. The only problem with this implementation is that there is no good way to enforce it's usage.

Conclusion

With the advent of ASP.NET, many of the hacks we have had in place have been removed. All of the view and controller related code is now in essentially one place instead of two. The defacto standard for writing view based application (MVC) is preserved.

Sample code

The sample code is provided as an illustration of how the architecture could be implemented. While it would be possible to use a configuration file instead of hard coding the getServerPage() information, I've choosen to keep the implementation simple. Comments are include to indicate possible improvements.

About the Author

Dave Bush has over thirteen years experience in IT, with experience in C++, Java, and VB. He has over 9 certifications from BrainBench. His company DMBCLLC can deliver code anywhere in the world. Visit his site at http://www.dmbcllc.com/ or reach him by email at davembush@dmbcllc.com.

Page 1

Scrum Coaching
Contact Us
Search ANY Site
Register for a Class
Agile .NET Blog
Online .NET 3.5 training
Instructor-Led
.NET 3.5 Training Online
ONLINE .NET 3.5 training online, instructor-led
NewTech's comprehensive hands-on, online .NET 3.5 training BOOTCAMP, using C#.NET and VB.NET, in a fast-paced 5-day hands-on format.
ONLINE ASP.NET training online, instructor-led
NewTech's intense hands-on, online ASP.NET training BOOTCAMP, using C# & VB.NET, in a comprehensive 5-day format.
Online .NET Training
1-Day Hands-On
.NET Training Online
online .NET for Managers training online
This is THE online .NET training class for project managers. The format is 1-day, seminar, with optional hands-on. Looking for online .NET manager training? This is it!
online LINQ .NET training online, scheduled, instructor-led
NewTech's intense 1-day hands-on .NET online LINQ training program, using C#.NET and VB.NET, includes hands-on exercises, 500+ page book, and 30 days of tech support.
Hands-On Java Training and JSP Training
Java Training BOOTCAMP™
Intense Java training for pro developers new to Java
JSP Training BOOTCAMP™
The most comprehensive JSP training & Servlet training on the market today
Quick Java and JSP Training for Developers
Java Training ASAP™
One code-intense day of lecture in Java fundamentals
JSP Training ASAP™
One code-intense day of lecture in JSP & Servlets
Quick Java & JSP Training for IT Managers
Java Training: Technology Platform Overview
For IT managers and developers new to the Java platform
.NET vs. Java Training: Platform Technology Overview
1 day of intense platform compare-and-contrast
BEA Weblogic Overview™
One day of lecture in J2EE fundamentals using BEA Weblogic
Perl Training
Perl Training BOOTCAMP™
Four-day hands-on training, for pro developers new to Perl programming
Other Developer Training We Offer
Can't find the class you want on the schedule? We offer lots of additional training for developers and managers. Check our extensive list of additional training here
ASP.NET Training BOOTCAMP™
Four-day hands-on training, for pro developers new to ASP.NET
.NET and Java Help, AFTER Training
Architecture and Mentoring
System design and coaching for your team
Staff Augmentation
Horsepower to complete your projects on time
Off-Site Technical Services
Development of your apps on time and on budget

[Home]   [Connecticut]   [Contact]  

Terms of Use
Since 1993, we have delivered training in cities as diverse as: Peoria ,Arizona | Corona / Salinas / Pasadena, CA | Torrance / Lancaster / Hayward, CA | Palmdale / Orange / Escondido, CA | Fullerton / Sunnyvale / Elk Grove, CA | Thousand Oaks / El Monte / Concord, CA | Simi Valley / Vallejo / Inglewood, CA | Visalia / Costa Mesa / Downey, CA | Santa Clara / West Covina / Roseville, California | Norwalk / Fairfield / Burbank, California | San Buenaventura / Richmond / Berkeley, California | Daly City / Antioch /Foster City, California | Milpitas / Sacramento, California | Lakewood / Fort Collins / Thornton ,Colorado | Westminster / Arvada / Pueblo ,Colorado | Bridgeport / Hartford / New Haven ,CT | Stamford / Waterbury ,Connecticut | Pembroke Pines / Hollywood / Port St. Lucie ,Florida | Coral Springs / Gainesville / Miramar ,FLA | Clearwater / Pompano Beach / Ft. Lauderdale / Orlando, FL | Savannah & Athens, Georgia | Burlington,Vermont | Naperville & Joliet ,Illinois | Springfield / Peoria / Elgin ,Illinois | Muncie, Indiana | Evansville & South Bend, Indiana | Muncie & Cedar Rapids ,Iowa | Kansas City / Topeka / Olathe ,Kansas | Lafayette ,Louisiana | Springfield / Lowell / Cambridge ,MA | Warren / Sterling Heights / Flint ,Michigan | Lansing & Ann Arbor,Michigan | Independence / St. Louis / Saint Louis,Missouri | Billings & Lincoln,Nebraska | Manchester ,New Hampshire | Bellevue ,Washington | Green Bay ,Wisconsin. Contact us to discuss bringing our training to your location!