Moving from ASP.NET Webforms to ASP.NET MVC#

I am currently moving a project from a typical webforms project to the new asp.net mvc framework project.  I am already seeing some huge benefits that I wanted to share with others.  Of course there is no viewstate in asp.net mvc and this has its advantages.  The most significant change is the size of my home page.  the amount of text in the page is down over 40%.  so my home page was 32K and now it is only 18K.  I am noticing even quicker page response times also running locally and on the server.  The page just seems to render faster, especially when hitting the back button.  Also it just feels cleaner without all those controls and I can have 100% control of the html that spits out.  It reminds me of back in the classic asp and PHP days, but without all the pain.  I did not realize how much I missed just writing straight html without controls.  

At first I thought that it would slow me down and that I would have to write more code,  but I think the opposite is true.   I don't have to deal with code behind any more and I can test so much easier now the action that every form calls.  I was able to convert an existing website that had Ajax control toolkit, membership services and several contact forms in about a week.  Not even that if you counted the hours.  Not too bad.  These tutorials really helped me out: http://www.asp.net/LEARN/3.5-extensions-videos/#mvc

We are about ready to go into production with these bits as we see that it is very stable and since we have the source code to the entire framework in our source tree, it feels safe since we can always fix a bug in the framework if we need to.  You can get the source code here: ASP.NET MVC Preview 2 Source Code

Thursday, May 22, 2008 9:47:11 AM UTC #    Comments [0]  |  Trackback

 

Amazon Kindle back in Stock!#

Ever since I have seen the Kindle - wireless reading device , I have wanted to buy one and read the Pragmatic Programmer on it among many other books.  I am trying to figure out the best way to get my wife to agree that this is the thing I need.  I am thinking that maybe reading on it instead of the laptop in bed might be a good reason since this laptop is so bright when she is sleeping sometimes.  You know when you really want something that you have looked at it so many times, trying to find the one reason why you shouldn't get it, but you keep reading good review after good review.  Maybe I can win one at a conference or if I visualize that it is in my hand, it will just magically appear.  That would not be the first time that has happened.  It did with my Zune 80.

Monday, May 05, 2008 11:55:26 AM UTC #    Comments [0]  |  Trackback

 

JavaScript to Managed Code in Silverlight 2 Beta 1#

I had to solve an interesting problem the other day for our new Silverlight 2 chat app for our site.  People were closing the browser window and not clicking the leave chat button which clears out their chat session.  So we needed to find a way to close out their chat session.  There are several ways to solve this problem, write a windows service to clear out stale sessions among many others, but the real solution was to figure out a way to have a Silverlight function get called from JavaScript when they close the browser window.

So the first problem to solve is to catch the browser window close event in JavaScript.  Here is the the script you need to do just that on all 3 browsers, Firefox, IE and Safari.

<script type='text/javascript'>
        
        window.onbeforeunload = function() {
            var slCtl = document.getElementById("Xaml1"); 
            slCtl.Content.mySLapp.StopChatting();
            alert("You have been logged out");
        }

    </script>

The Xaml1 control is referencing the asp:Silverlight control that is on the page.  the slCtl.Content.mySLapp.StopChatting();  call is calling a method on my c# class in the silverlight project.  In order to make this work you will need to do two things in your silverlight project.  The first thing you need to do is to register managed code for client script access.  In the Application_Startup method in App.xaml.cs, call the RegisterScriptableObject() method on the HtmlPage object and pass in your type that you want to reference in your script.  Here is a sample of how to do it.

 
using System.Windows.Browser;

namespace Chat
{
    public partial class App : Application
    {

        public App()
        {
            this.Startup += this.Application_Startup;
            this.Exit += this.Application_Exit;
            this.UnhandledException += this.Application_UnhandledException;

            InitializeComponent();
        }

        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // Load the main control
            this.RootVisual = new Page();

            //Setup some scriptable managed types for access from Javascript.
            ScriptableType st = new ScriptableType(); 
            HtmlPage.RegisterScriptableObject("mySLapp", st);

        }

        private void Application_Exit(object sender, EventArgs e)
        {

        }
        private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
        {

        }
    }
}
Now we need to create the ScriptableType class and add the ScriptableMemberAttribute 
attribute, which is required in order to expose the members to client script.
using System.Windows.Browser;

namespace Chat
{
    public class ScriptableType
    {
        public ServiceHandler svc;

        [ScriptableMember()]
        public void StopChatting()
        {
            svc = ServiceHandler.Instance;
            svc.StopChatting();
        }
    }
}
You can also return a type string if you want and then alert that string that is returned in JavaScript.
It really is a very powerful feature and I am very excited to use this power in many other ways. Happy coding!
Wednesday, April 30, 2008 11:12:40 AM UTC #    Comments [0]  |  Trackback

 

Building Visual Studio 2008 projects with TFS 2005#

When I upgraded to visual studio 2008, I tried to build out my 2008 project that was targeting 2.0 and it would not build out anymore because the version was not compatible with TFS 2005.  Turns out since there is a simple but irritating fix.  You need to open the .sln file in notepad and replace version 10.0 with 9.0 and then rename the file to a new one and use that in the build.  Remember to name it something different and then search and replace all the references to the old .sln to new one wherever it is referenced in the file.  Then be sure to remember to change the name of the .sln file in your tfsbuild.proj to point to the right sln.

Of course the better solution is to upgrade to TFS 2008, but that solution is not always the easiest because of money and time to upgrade the system. I am excited to upgrade soon, but this works for me now.

Monday, March 31, 2008 7:39:07 AM UTC #    Comments [1]  |  Trackback

 

Microsoft is going to give out dev tools for free to students#

I just saw on cnet news article tonight that Bill Gates is going to announce at Stanford on Tuesday, Feb. 19th that Microsoft will give away dev tools to college students and then high school students.   This is not just visual studio, but expression studio and even server 2003 and SQL dev edition.  Wow that is very cool and could help the shortage we have in developers in the U.S.

You can see more on this over at Channel 8 on this post http://channel8.msdn.com/Posts/2047/.    I am sure it will be all over the news in the morning.  This will change a lot in colleges across the world as the cost entry into learning and creating new .NET web applications and desktop apps just got very cheap and easier.  This will be very exciting to see the new apps that come out.

Tuesday, February 19, 2008 10:53:12 AM UTC #    Comments [5]  |  Trackback

 

Subsonic 2.1 Beta is Out#

SubSonic 2.1 Beta is Out.  Perfect timing.  I am speaking at South Florida Code Camp tomorrow morning on SubSonic and the future of it.  You can download the latest bits here on Codeplex.

Some really cool stuff coming out with SubSonic 2.1 including the Repository Pattern, SubStage, Linqy type queries with ASP.NET 2.0 and many bug fixes.  For people like me who have invested a lot of time with large projects and SubSonic, this is a very welcome release.  I cannot move many projects to 3.5 yet and this helps prolong the life of those projects without having to change any of the glue code that SubSonic helps so well with.

Saturday, February 02, 2008 9:48:09 AM UTC #    Comments [0]  |  Trackback

 

Tampa User Group Talk - ASP.NET Dynamic Data, Ajax and Silverlight using ASP.NET 3.5 Extensions Preview#

I am going to be doing a user group talk on January 28th 2008.  You will learn and see demos of some new data scenarios including MVC, ADO.NET Data Services, Dynamic data and the Entity Framework along with new Ajax history support and Silverlight controls for ASP.NET using the ASP.NET 3.5 Extensions Preview.  This release provides new features for ASP.NET 3.5 and ADO.NET in VS 2008.

Here are some good resources that you can tap into now and learn why this new stuff is so so cool.

I really hope that David Hayden shows up to keep me honest.  He is having also putting on an event called "Day of Patterns and Practices" on January 31st.  http://www.pnpguidance.net/  It should be a great event!

Friday, January 11, 2008 10:30:33 AM UTC #    Comments [0]  |  Trackback

 

My Zune 2 Review#

So I have had some sort of MP3 player since 2000 when I got my 6 GB hard drive creative mp3 player which looked like a cd player and hacked it to use a 20 GB hard drive.  So you could call me a veteran of MP3 players.  I used to download from Napster back in 2000 and started with subscription music with Napster in 2005, funny how we come full circle.  Anyway i have not even ventured out to find music for more than 3 years because i have had a subscription.  This is where the music industry needs to go and it is shocking that Apple would not offer it.  Anyway, back to my review.

I have to admit that while I have played with IPods, I have never actually owned one.  I have used a treo 600, then a treo 700w to play all of my music for the last 3 years.  I always like the approach of using an SD card to expand my space and now have a 4 GB card that only cost $30.  I have always been able to upgrade my space on my phone and can also download broadcasts since i use Verizon broadband from my phone.  My point is that all the features you see now with the IPhone and other phones have been around for years. 

So after the 300th podcast and 2 years on my phone from dotnetrocks and hanselminutes, I got sick of answering the phone and have it interrupt my listening.  That and having to remember to download it to my SD card which connected to the phone.  That is when i knew i needed a separate player for my podcasts.  I did not want an IPod because I prefer subscription music and I wanted wireless syncing.

Well now that I have been using my Zune 2 (80 GB version) for two weeks now, I am so thankful that I have one.  I get home and put it on my A/V Dock, which is just so cool that I can have it hooked up to my stereo and TV so i can see my videos and images along with listen to great music from my nice stereo.  Also with wireless syncing, as soon as I put the Zune in the A/V Dock, It starts syncing up with my computer that has already downloaded the latest podcasts for the day.  I was amazed when I accidentally found the power of this feature when I was working on my laptop upstairs while my Zune was charging in the wall and all of a sudden the Zune software pops up and starts syncing with my Zune which is downstairs.  So cool.  I am telling you Microsoft really handed Apple something to worry about with this device and software.  I already look at the IPod Classics as old school and although the ITouch is cool, it really is not that cool with only 16 GB max, more money and no wireless syncing. 

So i must say I am somewhat biased being a Microsoft MVP, but I have been waiting for a player like this for a long time and there is nothing quite like it on the market, so let the products speak for themselves.  If you like to listen to podcasts and do not want to have to pay for each track this the obvious choice.

Monday, December 17, 2007 8:19:07 AM UTC #    Comments [0]  |  Trackback

 

 

All content © 2008, Jim Zimmerman
Book
New Book
Links to me
On this page
Sponsors
Calendar
<May 2008>
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
Archives
Tags
Blogroll OPML
Technorati
Favorite Links
Disclaimer

Powered by: newtelligence dasBlog 1.9.6264.0

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

Send mail to the author(s) E-mail