Which Visual Studio Do I Need?

The “Visual Studio” moniker has expanded over the years to a full-fledged family of products tailored to facilitating the implementation and support of high quality software. The versatility of Visual Studio makes it a good choice for software development whether your language or framework of choice is .NET, web client, or open source.

The website www.visualstudio.com is the hub for all things “Visual Studio”. There is a lot of good content on this site, as well as access to free and trial editions of products. The challenge that this site has is how to distill the Visual Studio offerings into a format that a technologist, manager, or purchaser can absorb to make decisions on which software best satisfies their needs. Since Visual Studio has grown into multiple products, and each of those products has an ever-expanding feature set, the straightforwardness of conveyed information is often eschewed in favor of highlighting new and improved features. Industry terms and branded feature names are also commonplace in describing Visual Studio capabilities, making it harder to comprehend the amount of relevancy and value to your own development team.

So, with this in mind, let’s take a simpler look at Visual Studio from the ground up from the perspective of a decision maker needing to assess what software is needed for a software development team to work effectively.

Continue reading “Which Visual Studio Do I Need?”

Problems with Sitefinity Event Dates

I’ve hit quite a few issues while building a page that displays events in Sitefinity using just the out-of-box functionality. Along the way, I’ve logged a few support issues, but I decided to write it up from beginning to end to clear my mind and hopefully save others from getting stuck with similar problems.

Continue reading “Problems with Sitefinity Event Dates”

Why Entity Framework Include Method Doesn’t Always Work

I recently had a problem with the following code not working as expected:

var services = context.Benefits
    .Include(b => b.Services.Select(s => s.ServiceCategory))
    .SelectMany(b => b.Services)

I’m using a Select within the Include to load the ServiceCategory object associated with each Service in the Services navigation property of the Benefit object. I’ve used Include a lot in the past and never had a problem until now.

As it turns out, Include does not work if you change the shape of the query after specifying the Include method. In my case, SelectMany caused the shape to change from Benefit to Service.

Fortunately, the solution is simple. Specify the Include after changing the shape as follows:

var services = context.Benefits
    .SelectMany(b => b.Services)
    .Include(x => x.ServiceCategory)

I found the solution, and an explanation for this behavior, in an MSDN blog post.

Initial Files Created in the MVC3 Website Script Folder

When creating a new MVC project, a dozen or so JavaScript files are included by default in the Scripts folder. I haven’t been able to find any documentation on which ones should be included in a page in what situations, so I’ve put together the information in this article.

Continue reading “Initial Files Created in the MVC3 Website Script Folder”

Intro to Responsive Layouts

Recently, I’ve started to work on creating websites with responsive layouts. Responsive layout design means that the presentation of the website is adjusted to improve the fit at different resolutions. In the past, I have usually targeted 1024 as the minimum horizontal resolution that is needed for an optimal experience. But with phones and tablets being used more to browse the web, it’s becoming more important to give a first-rate experience to visitors using mobile browsers as well as desktop ones.

Unlike desktop browsers, mobile browsers automatically zoom out the page to fit the availability device resolution, so the user doesn’t have to deal with horizontal scrolling (unless zoomed in). The downside is that text gets cramped and hard to read, and clickable buttons and links are hard to tap accurately. Mobile-specific versions of website have been created to solve this problem. This made sense when mobile devices were primarily low-resolution phones. But recent model phones and tablets have much better resolutions that are capable of delivering a better experience than that offered by the low-resolution mobile-specific version of a website. What’s really needed is a modified desktop experience that is optimized to provide better legibility and usability on the reduced resolutions of mobile devices. Enter responsive design.
Continue reading “Intro to Responsive Layouts”

Markup Rendered by ASP.NET MVC HTML Helpers

ASP.NET MVC providers a number of HtmlHelper methods for rendering markup based on the view model.
The general strategy used by the helpers is:
  • A helper that directly correlates to the input type renders without any additional decoration of the markup.
  • The Editor(For) and Display(For) helpers may render addition CSS classes or specialized markup.
  • When a complex type is passed to the Editor(For) and Display(For) helpers, then container markup surround each simple type within the complex type.

Continue reading “Markup Rendered by ASP.NET MVC HTML Helpers”

Write better CSS with Sass and Compass using Visual Studio

I am pretty new to Sass and Compass, and I’ve experienced a learning curve with integrating it into my web development process. In this article, I’ll share my experiences with the technology and how I set it up and used it in a Visual Studio .NET environment.

Continue reading “Write better CSS with Sass and Compass using Visual Studio”

Consumption of Data in MVC2 Views

The following data sources are implicitly available as properties of a View:

  • ViewData
  • ViewData.ModelState
  • ViewData.Model (or more simply just Model via a shortcut property)
  • TempData

TempData is a special case that has been previously covered. The other three all relate to ViewData, but are substantially different from each other. Understanding these differences is important; otherwise it can lead to unexpected behavior when reading and writing ViewData and Model values.

Continue reading “Consumption of Data in MVC2 Views”

Default Model Binding Behavior in MVC2

This article explains the key concepts to be aware of with model binding in MVC2.

When an HTTP request is made to the server, request routing directs it to a Controller for execution. The Controller collects HTTP values in the request and loads them into a ModelState dictionary, which is used throughout the MVC request lifecycle. In this article, various ways in which ModelState can be consumed within the Action are described. ModelBinders provide the logic for converting the ModelState data into simple and complex types variables. The default ModelBinder used by MVC is very versatile.

Continue reading “Default Model Binding Behavior in MVC2”

Using MVC2 TempData with the PRG Design Pattern

Post/Redirect/Get (PRG) is a common design pattern recommended for use with HTML forms. Redirecting after a successful form post can help avoid accidental duplicate submissions and allows a browser to behave more intuitively with bookmarks and the refresh button. Most MVC examples follow this pattern:

public ActionResult Edit(int id, Contact contact) {
    if (ModelState.IsValid) {
        // Submit values to the database
        return RedirectToAction("Index");
    return View();

As you can see, if the POST action is completed successfully, then a REDIRECT occurs to GET a new page. If there is a validation error, then the posted data is returned back to the client through a view (usually through the same view). ViewData keeps track of posted data throughout the request lifecycle. You can add and modify values in this collection during action processing. However, when a RedirectToAction is executed, the ViewData is lost. This is a good thing since the redirect causes a new GET request to be issued which, according to RESTful principles, should not track any state from a preceding request.

However, sometimes we want to internally pass information to the next request. This could be implemented as a URL parameter, but then the information would be present whenever that specific URL was requested rather than just one time in the next request after the post that issued the redirect. A common need, for example, is to display a confirmation message after an update from the previous page has completed successfully.

Continue reading “Using MVC2 TempData with the PRG Design Pattern”