web 2.0

How to Localize an ASP.NET MVC Application

While working on WeBlog this week I decided that I needed to start thinking about localization. If you have never heard the term “localization” before then its just a fancy way of saying that I want my application to be multi-lingual. In order to localize an application in .NET, you generally need to create a separate resource files for each language you want to support. In an ASP.NET MVC application, the resource files should be placed in a folder called App_GlobalResources. The folder can be created by right clicking on your project and selecting Add –> Add ASP.NET Folder –> App_GlobalResources. The resource files follow a naming convention. The first part of the name is the user defined part, for WeBlog we called it “Strings” but it could be whatever you want. The second part of the string is the Culture. For English the culture is “en”, for French the culture is “fr”, and so on and so forth. Here are few examples: Prefix Language Culture ... [More]

Advice for Aspiring ASP.NET Web Developers

For some reason, I have been asked the same question a lot lately. Which is, "I am new to development. Do you have any tips/tricks/suggestions to get me up to date on ASP.NET?". My knee jerk response to this question is usually to point people to Google for the answers. However, there is so much information floating around on the web these days that it can be overwhelming when you try to comb through it all. So, if you are an aspiring ASP.NET web developer then I hope you will find the following links, tips and tricks useful. The Basics of Web Development No matter what web technology you develop with, there are some basics that you should understand first: HTML – If you have never had exposure to HTML then you are going to want to visit W3 schools tutorial page before going any further. In its most primitive form, HTML is very simple and easy to use. Cascading Style Sheets (CSS) is a style sheet language used to describe the presentation semantics (that is, the look and form... [More]

Building an RSS Feed in ASP.NET MVC

When building a website it is common to expose an RSS/ATOM feed for your content. Feeds serve two main purposes. The first, is that it allows other sites to consume your content for syndication. For example if you write .NET articles, there may be other partner sites that subscribe to your feed and dynamically pull in your content.  Secondly, feeds allow users to subscribe to your site so they can get notifications when your content is updated. This is especially relevant for sites with irregular content updates such as a personal blog. In the .NET 3.5 framework there is a namespace titled System.ServiceModel.Syndication which very few people seem to know about. The classes contained in this library allows you to create and consume RSS feeds with minimal effort. I recently created a feed for my WeBlog application. I was astonished about how little time it took to implement an RSS Feed. Instead of weighing you down with all the details...I'll let the code do the talking: public ... [More]

Open Data Protocol AKA OData

I have been hearing the term OData a lot lately but I had no idea what it really was. So I did a little searching and stumbled upon odata.org. OData or the Open Data Protocol is a new format for sharing data on the web using REST (Representational State Transfer). The text book definition of OData from the website is as follows: The Open Data Protocol (OData) is an open protocol for sharing data. It provides a way to break down data silos and increase the shared value of data by creating an ecosystem in which data consumers can interoperate with data producers in a way that is far more powerful than currently possible, enabling more applications to make sense of a broader set of data. Every producer and consumer of data that participates in this ecosystem increases its overall value. At the heart, OData is really just producing an ATOM or JSON payload. Since ATOM and JSON are universally known, OData is not tied in any way directly to the .NET family of languages. OData already has ... [More]

Dynamic Casting with .NET

I recently was working on a project where I needed to store settings or various data types into a database table. Since most of the settings were singular I ended up with a table that had two columns which were titled name and value. The name and value field of the Setting table are both defined as varchars ( or strings). By defining the value field as a string, I can serialize any object to the table by using the ToString() method. Over time my application could grow to have dozens of settings of varying data types. So I needed a mechanism to load the settings from the table and assign them to an object. While loading each setting, I need to dynamically determine the data type of each field and dynamically cast it to the correct type. Since my project is written in MVC I developed a Model class which represents all of the settings that I need to reference. Here is the definition: namespace WeBlog.Models { public class SettingsModel { //general settings [... [More]