ASP.NET MVC

2010 Goals

Thursday, 28 January 2010

Posted by Sébastien Lachance with Comments (0)

2010 will be a great year and I’m sure that my life will change dramatically. I have a whole bunch of ideas and things I want to do.  Here is a list of my “professional goals”.

Become an expert with ASP.NET MVC.

Ever since I first heard of ASP.NET MVC, I knew I should become proficient in it. But I can’t control the type of project I’m working on, so I neglected to do my homework and stay up to date.

Get some more experience with web design (CSS, XHTML)

A big gap to fill. I’ve made some progress but still not able to do it efficiently. I will probably pick up some books and try to design web site from scratch just for gun.

Write a jQuery plugin.

I have some ideas of plugins that haven’t made it to general release. This year, I will definitely launch one to have a real experience with launching an open source project and responding to feedback.

One contribution to an open-source project.

Something else than the jQuery plugin mentioned earlier. I have made some “improvement” to BlogEngine.Net and maybe I will submit them some changes I’ve made.

At least 100 blog posts and 100 feed reader.

95 posts to go and around 50 more readers. Completely feasible. I also picked some tips while I had a complete lack of posts for some month and I am now ready to apply them.

GTD

I need to finish Getting Things Done and try it for some months. A goal that I really need to complete this year.

Get back into the shape of my life.

I took some weight since the wedding in October 2009 and I can now see how it affect my health. So I am ready to take care of this again. It may not looks like a professional goal but I’m sure It will have a big impact in the end.

 

Technorati Tags: ,,,


ASP.NET MVC Request Handling Poster

Thursday, 08 October 2009

Posted by Sébastien Lachance with Comments (0)

niceposter If you need to visually look at what happens on an ASP.NET MVC request, look no further. Steve Sanderson has created a poster that will help me better understand the request pipeline. I have been looking for a long time for a resource like this, I’m a visual learner (I think) and seeing the plumbing visually is just great.

Thanks for Steve Sanderson for sharing his Request-Handling Pipeline Poster.



Where did my strongly-typed action link has gone in ASP.NET MVC?

Thursday, 23 October 2008

Posted by Sébastien Lachance with Comments (0)

<%= Html.ActionLink<EquipmentController>(c=>c.Show(equipment.Number, equipment.Letter), "See") %>

If you have converted your old ASP.NET MVC Preview * application to ASP.NET MVC beta or following tutorials that were made with those old versions, you may have wondered where the strongly-typed action is gone.

The reason is because of some features that can still evolve in future release of ASP.NET MVC. And since it will be fully supported in the version 1 of the product, and for backward compatibility, they cannot include it in the released assemblies. But, fear not, the feature is available in the ASP.NET MVC Futures assembly.



ASP.NET MVC Beta

Friday, 17 October 2008

Posted by Sébastien Lachance with Comments (0)

It's finally there and now come with a "go-live" license. I have been waiting for a long time for it to be enough stable (never had any problem before) to use it for "real" clients (not for my own personal use).

I have been reading this ASP.NET MVC beta post by ScottGu which is describing a bunch of new features and I found 2 that I personally find great.

The first one is about the new "Add View" menu. This option enable us to make a strongly typed view easily. Not that it was hard to do before. But it's a nice feature that will improve our experience with ASP.NET MVC.

The second most enjoyable feature is the addition of the FormCollection parameter to an action. Unit testing without requiring to mock anything is great.

And finally, ScottGu is talking about something new for ASP.NET WebForms in the new .NET 4.0. We will noew have complete control over the ClientId property.



New code drop to the ASP.NET project on Codeplex

Tuesday, 13 May 2008

Posted by Sébastien Lachance with Comments (0)

  • 05/12 Source code release of the ASP.NET AJAX Script Profiler helper control: To support the ASP.NET AJAX script combining feature which shipped in the .NET Framework 3.5 SP1 Beta release, we've added the ASP.NET AJAX Script Profiler helper control source and binaries to this project. This control helps you to identify the scriptreferences used in your ASP.NET AJAX page to use with ASP.NET AJAX script combining. You can find this release here: ScriptReferenceProfiler Source and Binary Release. In addition this control is used in a Screencast for ASP.NET AJAX script combining on the ASP.NET site.
  • 05/12 Release of the ADO Data Service AJAX Client : The ADO Data Service AJAX Client Library enables you to consume an ADO.NET Data Service from client script in an ASP.NET AJAX Web page.

Read more on the codeplex page.

I'm really wondering how I can keep up with all these new things to try. Well, I guess I will really need a pill to stop sleeping someday.



Mocking the HttpContext in ASP.NET MVC

Thursday, 08 May 2008

Posted by Sébastien Lachance with Comments (0)

I just got a hard time figuring how I could be mocking the HttpContext so that I would be able to mock HttpRequest. But once you understand the principle, it is fairly easy.

First thing we need to know is that the HttpContext is held inside a ControllerContext object. Once we have instantiated one, we can then put it inside our controller.

controller.ControllerContext = new ControllerContext(mockedhttpContext, new RouteData(), controller);
 
Where mockedHttpContext is your mocked HttpContextBase object.
 
Inside the HttpContextBase object reside a lot of useful stuff that can replace with our mocks. By example, the HttpRequest, HttpServer, HttpApplication, etc, are all contained inside. So, getting familiar with this basic knowledge is a must to do testing usefully.
 
Next post : Mocking HttpRequest.Form to return what we want.


Testing controllers in ASP.NET MVC aka ActionResult

Tuesday, 06 May 2008

Posted by Sébastien Lachance with Comments (0)

I haven't really done any testing in ASP.NET MVC until now. I started the development of a more serious application and decided to do it TDD. My first test was to make sure the Index action render the Index view. So as an informed developer, I started reading some blog posts to discover that in order to test a controller you need to mock a lot of things. I followed the screencast of Scott Hanselman and implemented his MvcMockHelper. It didn't worked. The ViewContext on the view engine remained null, resulting in an NullReferenceException. I downloaded the source of the last build to see for myself what was wrong. Surely I don't understand, because nowhere in the source they are setting the ViewContext on the ViewEngine. They just fill a RenderViewResult object and return it back.

This is how I figured out how we can now test controllers. With the new Interim build of the 04/16, we don't have to mock the HttpContext, HttpRequest and so on anymore. No need to do a fake view engine and no more mocking needed to test the RenderView method.

[Test]
public void Index_Should_Set_The_Index_View()
{
EntryController controller = new EntryController();
var result = (RenderViewResult)controller.Index();

Assert.That(result.ViewName, Is.EqualTo("Index"));
}

So if you have any other operations (RedirectToAction and Redirect for example), it will return an object of type ActionResult that you can cast to the appropriate inheritor (RenderViewResult, ActionRedirectResult, HttpRedirectResult) to get a lot of information that you would have to retrieve manually with a mock.

I really like the simplicity of it and can't wait to see more improvement. This is an immense opportunity to learn a great deal of different things.



Quick Start with ASP.NET MVC Interim Source Code

Tuesday, 06 May 2008

Posted by Sébastien Lachance with Comments (0)

This is intended to be a quick start for anyone who want to start playing with the latest version of ASP.NET MVC without going through the origin and goals of the MVC pattern. I will use the ASP.NET 0416 MVC Interim Source Code Release for this. Keep in mind, that this will probably all change in a near future.

First step, download and build the source. You will need to have the Moq library (more about this mocking framework in a future post).

Second, download and install the Visual Studio MVC Templates (execute the vsi file).

Third, start an ASP.NET MVC project.

I have two useful resources to share with you. I believe they will give you a head start.

You have the Scott Hanselman's screencast series on the ASP.NET web site. And you have the MVC Storefront series from Rob Conery.