Home > MVC, Uncategorized, Visual Basic > ASP.NET MVC & VB – Where are the examples

ASP.NET MVC & VB – Where are the examples

I finally got around to teaching myself ASP.NET MVC (using 4.0 / razor / Entity Framework 4.1 / VS 2012 RC) and found myself in a bit of a bind today. Despite the fact that I am a VB.NET MVP I have been working in C# just so I can keep my chops up with the language. I never get the chance at work to use C# so I force myself to do all personal projects in C#. The short of it is that I love MVC 4 and especially the razor syntax. Very powerful, very flexible. I have been catching on quickly enough and have found ample examples on the web to do what I need, which is very comforting to know that there is a huge amount of support for what is still not the mainstream web technology for MS (yet!).

And then I started up a test project at work to show some colleagues. It was in VB.

The experience could not have been more night and day. Examples of razor code segments in VB on the Googlewebs is like finding a needle in a haystack. To clarify, I was searching for specific answers — if I just did a general search like “MVC4 VB.NET” then I would find basic tutorials easy enough. But I’m not looking for encompassing tutorials. I’ve already started getting into the details of implementation so I need to solve specific issues. Unfortunately that sort of content appears to be blanketly in C# and I have to say that this is disheartening to a professed VB-enthusiast. For instance, I was trying to find the syntax for declaring a WebGrid HTML helper in razor (recall that I am new to MVC) so whatever I had used back a few weeks ago was half-fading from memory. Not a problem though – I’ll just find a quick sample from some forum thread or article just to get the ball rolling – a mix of search terms that included “MVC3”, “MVC4”, “VB.NET”, “webgrid” and “razor” I eventually had to give up around my twelfth result and translate a C# example instead. Honestly, I would have done this much earlier but I was just amazed at the lack of VB coverage. I pride myself on finding things fast through search – even with technologies I’ve never even seen before. This however was debasing. (For the record is a good reference that has ample dual language examples.)

So what’s with the near absence of VB code samples anywhere – in MS documentation or in developer forums. I can only conclude that ASP.NET MVC 3/4 is not a technology widely adopted by VB.NET developers. I know there are plenty of VB.NET developers out there but I suspect that the perception that VB’ers are mainly stuck on Windows client applications (Winforms mostly) may have some truth to it. Windows development does constitute about 90% of the content in the MSDN Visual Basic General forum forum. It’s what I have done primarily for the last seven years. The VB language team at Microsoft, through the effort of achieving “language parity”, has done a stellar job of elevating the language to the position of true equal to C# in terms of power and flexibility (with a very few exceptions) with the onset of .NET 4.5. Its detractors have little more than perception and job market opportunities to point to for C# superiority. Unfortunately for VB those things count for a lot. Too bad though. Vb.NET is a great language that, together with the power of the Visual Studio IDE, can offer blinding fast speed for the experienced developer as well as clear and simple readability. As evidence I offer case-insensitivity, auto-completion, code prettification and the lack of superfluous curly braces.

One last gripe with my brief exploration of MVC 4 with VB.NET. When trying to create an out of the box “basic” solution on my home machine (VS 2012 RC) I received the following error from the IDE at the tail end of generating the solution:

MVC 4 Error

I believe this may be behind my inability to access the WebGrid class in code on the razor form – thank goodness my real project is done in C#. I’ll have to assume this is some issue with VS 2012 RC (since the project I did at work was with VS 2010 SP1) but this whole business with VB has got me paranoid now. The second time I started a VB MVC 4 project at work using VS 2010 I noticed another issue. With VB defaults set to Option Strict On (which is recommended) some of the auto-generated code fails to compile because of loose casting. My guess is that the generation code was written for C# first and then ported to VB CodeDOM parser without a proper review of project context. This just suggests to me that VB was an afterthought. Kinda pisses me off, really.

Advertisements
Categories: MVC, Uncategorized, Visual Basic Tags: , ,
  1. July 6, 2012 at 9:04 am

    great topic…and easy to understand

  2. Ratna Swami
    September 1, 2012 at 5:59 am

    Hello DigBoy,

    Absolutely correct. You have brought out a REAL ISSUE that affects a huge number of developers. I could not agree more with your views.

    VB does enjoy the advantages which you have specifically mentioned; more so in many corporate ‘I-want-it-yesterday’ environments. .

    There are many,..,many thousands of developers on WebForms VB (certainly in India ) who would want to move over to MVC VB; particularly due to its own advantages as well as in developing JQueryMobile based applications. What puts them off is that ALMOST ALL of the examples on the Web are in C#.;

    Other than the ‘Movie’ Tutorial by Asp.Net which also calls for familiarity with Entity Framework as well as Razor, thee are ABSOLUTELY NO GOOD TUTORIALS of MVC VB, which may be easily found. Even this tutorial describes files as ‘.cs’ 😦 perhaps because this was also converted from its C# Big Brother!!

    I sincerely hope Microsoft recognizes this disturbing fact and takes effective action.. At the least Microsoft MUST provide all their Tutorials on New Technologies in Visual Basic along with the ones in C#.

    e.g. The Microsoft article on JQuerMobile with MVC and Windows Phone is available only in C# on its site!!!!!

    THANKS AGAIN FOR BRINGING THIS UP! HOPE Microsoft notices this!!!!!

    • digboy
      September 1, 2012 at 12:02 pm

      Thanks Ratna. I wish I could say this issue was conained to Microsoft alone but perception in the general community is the driver here. I’ll do my part to raise awareness.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: