Udostępnij za pośrednictwem


Playing with ASP.NET MVC.

I must say, ASP.NET has always been a love/hate relationship with me and it has nothing to do with the technology, more my mind trying to melt to the way ASP.NET works vs JSP/Coldfusion.

Hey, I spent 10 years doing the later, groking ASP.NET in terms of concepts has always tripped me up.

ASP.NET MVC however for me is very similar to Mach-II in Coldfusion. So much so, I wanted to look for a way to have a Controller sit in one spot, but bring in Views from another (ie not automated, but wanted to configure it myself).

I searched online as best I could and couldn't find it, and part of the blame for this is simply "how do I phrase the question".

I then went back to what i've jokingly called "MVC Bible"  Stephen Walther's blog. I clicked on his Tips (as I was frustrated and decided to take my mind off the problem and see what's good in MVC via Stephen) and then I noticed this post on how to do it..

The magic answer is:

 

   1:     public class UserProfileController : Controller
  2:     {
  3:         public ActionResult Index()
  4:         {
  5:             ViewData["Title"] = "User Profiles";
  6:             ViewData["Message"] = "Welcome to ASP.NET MVC!";
  7:             return View(@"~\Views\Admin\Security\UserProfiles\ViewAllUsers.aspx");
  8: 
  9:         }
 10:     }

It's that simple.

Ok, with that, I went off and continued coding and it all now is singing together nicely. The point of this thread is that I love how Stephen's structured this approach, basically "Tips for MVC".

I'd love to see someone do this for WPF & Silverlight in such a structured fashion.

Anyone?