Thoughts on .Net & Coding
.Net Articles, tutorials, reviews, code and more...
-
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.
-
Working with Cookies in Web API and HttpClient
ASP.NET applications often use cookies to store user specific pieces of information. Not just web forms and MVC applications, Web API too can use cookies. Sometimes developers device an authentication scheme revolving around cookie as an authentication ticket. Although this article won't show you how to develop such a scheme, it illustrates how cookies can be issued and used in Web API. Specifically you will learn: How to set cookies from a Web API controller and read those cookies in a client application and how to set cookies from a client application (HttpClient) and read those cookies in a Web API controller.
-
Learn ASP.NET MVC5, EF6, Web API 2, VS 2013 in Thane
I will be conducting a 5 day intensive training program on ASP.NET MVC in the month of July 2014. Learn VS2013, MVC5, EF6, Web API 2 and more. Small batches, personal attention and real world examples. Registration has already started. In case you or your friends are interested to join please get in touch with us as soon as possible.
-
Understanding Dependency Injection
If you ever developed ASP.NET MVC applications you probably have come across this term - Dependency Injection. Dependency Injection is a way to implement the Dependency Inversion Principle. Simply put, Dependency Injection is a design pattern that helps a class separate the logic of creating dependent objects. The result of this separation is a loosely coupled system where there is no rigid dependency between two concrete implementations. This article discusses what Dependency Injection is and illustrates its use in an ASP.NET MVC application.
-
Dealing with Multiple Instances of Partial Views and Model Binding in ASP.NET MVC
ASP.NET model binding is quite powerful and flexible. It caters to most of the scenarios without much configuration from developers. However, at times you may need to intervene in order to achieve the desired model binding effect. One such situation is when you use multiple instance of a partial page on a view. This article shows one possible approach to deal with such situations.
-
Writing C# Code Using SOLID Principles
Most of the modern programming languages including C# support objected oriented programming. Features such as encapsulation, inheritance, overloading and polymorphism are code level features. Using these features is just one part of the story. Equally important is to apply some object oriented design principles while writing your C# code. SOLID principles is a set of five such principles--namely Single Responsibility Principle, Open/Closed Principle, Liskov Substitution Principle, Interface Segregation Principle and Dependency Inversion Principle. Applying these time proven principles make your code structured, neat and easy to maintain. This article discusses SOLID principles and also illustrates how they can be applied to your C# code.
-
Cascading DropDownLists using "Eager Loading" on client side
One of my earlier articles shows how to create cascading DropDownLists by making Ajax calls to the MVC action methods. While that approach is quite common and popular recently a reader asked whether something similar can be done without making any Ajax calls. If you want to implement cascading dropdownlists purely on client side then you will need to "eagerly load" all the data needed by them at the time of loading the page. This data can be stored in a hidden field and used as and when needed. Obviously this technique is not suitable for huge amount of data since everything is loaded at once on the client side. However, if the data is small and you understand the implications of loading it in advance here is how you can accomplish the task.
-
10 Things to Keep in Mind while Developing a New ASP.NET Web Forms Application
Many developers are opting for ASP.NET MVC for their new web applications. However, this may not be always possible (reasons can be many and valid in a given context) and you might be required to use Web Forms for your new projects. In such cases novice developers have this doubt - "If I develop my project using Web Forms and later want to migrate to MVC, how difficult this task would be?". There is no single answer to this question. However, if you follow certain guidelines while developing a Web Forms project today, at later stage migrating to MVC would be less painful than otherwise. Here I have listed my top 10 recommendations in dealing with such a situation.
-
Overview of Design Patterns for Beginners
Modern software development needs to address complex business requirements. It also needs to take into account factors such as future extensibility and maintainability. A good design of a software system is vital to accomplish these goals. Design patterns play an important role in such systems. While learning a programming language beginners often focus on language syntax and usage techniques. However, it is also important to understand the basics of good software design. To that end this article gives a quick understanding of design patterns. It discusses what design patterns are, their benefits and classification.