Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Contents tagged with .NET Framework

  • Convert JSON and XML markup into C# classes using Visual Studio

    Visual Studio provides a plethora of features that make you more productive. One such feature is converting XML or JSON markup into C# classes. This article discusses this feature with a few examples. XML and JSON are the two commonly used data formats for serializing data over the wire. Many a times you need to map XML or JSON markup to C# classes. No doubt, you can create these C# classes manually but Visual Studio can provided a good starting point by automating the process.

  • Use Lazy Initialization to Delay Object Instantiation

    It is a common practice to declare object variables as the class members and initialize them in the constructor of the class. At times, however, you need to delay the object instantiation until its first use. One way to achieve such an deferred object instantiation is to write custom code that implements Lazy Load pattern. An easy alternative is to use .NET framework's inbuilt lazy initialization feature. To that end this article explains the later approach.

  • Creating Your Own "TempBag" in ASP.NET MVC

    Some time back during one of my training programs I was asked this question by a beginner in ASP.NET MVC - "Can we have TempBag wrapper for TempData just as we have ViewBag for ViewData?" Whether such a wrapper is needed is not is a different question but if you wish you can create one using dynamic objects of C# language. Here I am going to show a quick way to wrap TempData into our own TempBag and then using it in the controller and view.

  • Video : How to Organize Your ASP.NET MVC Solution in Visual Studio?

    A lot of beginners ask this question - How should I organize my MVC projects? There is no fixed answer to this question because a lot of things depend on the size and complexity of the system being developed. However, beginners need a starting point from where they can take it forward. To that end, this video shows one possible organization of various parts of an MVC application. Remember that my aim is to present a simple and structured organization that can easily be extended or modified as per requirement.

  • Aggregating RSS Feeds - Quick code sample

    .NET framework provides classes to read and write RSS and ATOM feeds. I already wrote a couple of articles illustrating the use of these classes. These classes reside in System.ServiceModel.Syndication namespace and primarily work with one feed at a time. Sometimes, however, you need to aggregate multiple feeds to create a single feed. The code sample below shows you how to accomplish this in an ASP.NET web form.

  • Using Visual Studio Debugger Attributes

    Visual Studio provides a rich debugging experience to developers, helping them write robust and bug free code. In simple projects, the inbuilt facilities of Visual Studio debugger may be sufficient for your purpose, however, while debugging complex projects you may want to enhance the debugging experience further. Luckily, Visual Studio offers debugger attributes that help you do just that. Debugger attributes allow you to customize the way Visual Studio debugger steps through your code and also the display of your types. This article explains some of the important debugger attributes along with debugger type proxies and visualizers.

  • Using DynamicObject and ExpandoObject

    C# is primarily a statically typed language. That means the compiler needs to know in advance about the data type of a variable. In the absence of this information, the compiler will throw a compilation error and will refuse to compile the code. In spite of the advantages offered by the statically typed languages, dynamic languages have their own place in application development. For example, most of the web sites developed today make use of JavaScript in some way or the other. Languages such as Python and Ruby are also popular amongst developers. The C# language now supports dynamic features through Dynamic Language Runtime (DLR). Part of these features include dynamic types, DynamicObject Class and ExpandoObject Class. This article explains these features and provides examples illustrating how these features are used.