background preloader

Technical Funda's

Facebook Twitter

6 important .NET concepts: - Stack, heap, Value types, reference types, boxing and Unboxing. Download source code - 42.5 KB Introduction This article will explain six important concepts: stack, heap, value types, reference types, boxing, and unboxing. This article starts explaining what happens internally when you declare a variable and then it moves ahead to explain two important concepts: stack and heap. The article then talks about reference types and value types and clarifies some of the important fundamentals around them. The article concludes by demonstrating how performance is hampered due to boxing and unboxing, with a sample code.

Watch my 500 videos on various topics like design patterns, WCF, WWF, WPF, LINQ, Silverlight, UML, SharePoint, Azure, VSTS, and a lot more: click here. You can also catch me on my trainings here. Image taken from What goes inside when you declare a variable? When you declare a variable in a .NET application, it allocates some chunk of memory in the RAM. Stack and heap Value types and reference types Source code. Dependency Injection and Inversion of Control with ASP.NET MVC. As you delve more into ASP.NET MVC you start to come across a whole new way of doing things that Web Forms development didn't really expose you to. Inversion of Control (IoC) and Dependency Injection (DI) are two phrases that crop up a lot in the MVC space. So what are they all about? And should you care? I should start by stating the IoC and DI are not unique to ASP.NET MVC. They have been around a long time. It's just that MVC supports these notions particularly well.

IoC is a principle, or an architectural pattern. Just to clear up any initial confusion, yes - the example above is more or less the same code twice. There is no separation of concerns here in that the data access layer is embedded in the Controller. "Oh, but that will never happen to me", you say. When you view Data Access as a "component" of your application, you should also start to see that there are other areas in an application which could be viewed as components. Dependency Injection and this: Right. IoC Containers. An Introduction To Performance Counters. Download source - 8.55 Kb Introduction Although the .NET Framework provides usage of performance counters under the System.Diagnostics namespace, for some reason, documentation on it does little cover using performance counters for average duration per execution.

When starting using PerformanceCounterType.AverageTimer32, performance monitor did not show the expected results. I started to dig into CodeProject and some newsgroups, and found many articles covering the same problem. After I found the solution, I started to write an article, which introduces using performance counters in .NET and especially how to use AverageTimer32 performance counter. So here it is! I am sorry, that I only have German Windows editions, so the images contained in the article contain German names for buttons, etc.

Getting started Performance counters can monitor system components such as processors, memory, and network I/O. Performance counters can be made visible using the Performance monitor (perfmon.exe). ViewState: Various ways to reduce performance overhead. Download demo - 10.7 KB Table of Contents Introduction In this article, I am going to explore the ViewState. ViewState is one thing that I always like to use. It makes life easier. As we all know, Viewstate is one way of maintaining the state in web applications. As we know, a web page is created every time when a page is posted to the server. But how are these values maintained? In new era applications, we use lots of heavy controls like gridviews etc., on our pages which makes the page size exponentially heavy. Here, I am going to discuss how we can reduce the performance overhead caused by View State. What is ViewState As we all know, the Web is a stateless medium; i.e., states are not maintained between requests by default.

Various State Management technique in ASP.NET Here, we going to discuss one of the client state management techniques: ViewState. So where does the ViewState gets stored? Problems with ViewState The ViewState is stored on the page in the form of a hidden variable. Mastering Debugging in Visual Studio 2010 - A Beginner's Guide. Table of Contents Introduction In the software development life cycle, testing and defect fixing take more time than actually code writing. In general, debugging is a process of finding out defects in the program and fixing them. Defect fixing comes after the debugging, or you can say they are co-related. When you have some defects in your code, first of all you need to identify the root cause of the defect, which is called the debugging. When you have the root cause, you can fix the defect to make the program behavior as expected. Now how to debug the code? How to Start? You can start debugging from the Debug menu of VS IDE.

Figure: Start Debugging There is another way to start the debugging by "Attach Process". We generally start debugging any application just by putting breakpoint on code where we think the problem may occur. Breakpoints Breakpoint is used to notify debugger where and when to pause the execution of program. Figure: Set Breakpoint Debugging with Breakpoints Step Over Step Out. URL Routing with ASP.NET 4.0. Download demo app - 376.23 KB Table of Contents Introduction One thing that has always pinched me is the long URLs that I used to see in several of my projects. Due to better manageability, I used to have several folders, i.e. folder hierarchy for maintainability of my application. But the thing that I didn't ever like was the full physical path of pages in URLs.

There are other ways which allow us to get rid of it like URL rewriting, but I didn't like that. We could also have our own custom URL route handler or some third party solution, but they have never been strong enough for an application. Frankly speaking, one of my clients asked me several times, "Why does this .aspx extension displays in the URL" and also told me that he does not like these long URLs. But when Microsoft released ASP.NET MVC 2 with .NET Framework 3.5 SP1, and provided this Routing feature with it, I was very happy and started exploring it. Now Microsoft introduced URL Routing with ASP.NET 4.0. Prerequisite Note: A Walkthrough to Application State. Table of Contents Introduction There are a lot of articles available on different ways of managing the states in the web.

I was not able to find details on Application Object and events. So I read different books and articles and thought of sharing my knowledge with all of you. Hope you will like it and give your feedback and suggestions. As we all know, web is stateless. Figure: Options available to maintain the state There are lot more written about most of them. Application LifeCycle First, I am going to explain ASP.NET Application Lifecycle. ASP.NET uses lazy initialization technique for creating the application domains, i.e., Application domain for an application is created only when the first request is received by the web server. Stage 1: User first requests any resource from the webserver. I'll explain the points one by one. Stage 1: The Application life cycle starts when a user hits the URL by typing it in the browser. Figure: URL Processing Figure: ASP.NET Handling first request. Maoni's WebLog.

How to: Pass Values Between ASP.NET Web Pages. The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location. If your application redirects (navigates) from one ASP.NET Web page to another, you will frequently want to pass information from the source page to the target page.

For example, you might have a page where users can select items to purchase. When users submit the page, you want to call another page that can process the information that the user has entered. A Visual Studio Web application project with source code is available to accompany this topic: Download. You can pass information between pages in various ways, some of which depend on how the redirection occurs. Use a query string.Get HTTP POST information from the source page. The following options are available only when the source and target pages are in the same ASP.NET Web application. To use a query string to pass information To use session state to pass information. Methods GET and POST in HTML forms - what's the difference? In HTML, one can specify two different submission methods for a form. The method is specified inside a FORM element, using the METHOD attribute. The difference between METHOD="GET" (the default) and METHOD="POST" is primarily defined in terms of form data encoding.

The official recommendations say that "GET" should be used if and only if the form processing is idempotent, which typically means a pure query form. Generally it is advisable to do so. Content: The fundamental differences between "GET" and "POST" The HTML specifications technically define the difference between "GET" and "POST" so that former means that form data is to be encoded (by a browser) into a URL while the latter means that the form data is to appear within a message body.

The HTML 2.0 specification says, in section Form Submission (and the HTML 4.0 specification repeats this with minor stylistic changes): In the HTTP specifications (specifically RFC 2616) the word idempotent is defined as follows: You've been HAACKED. Garbage Collector Basics and Performance Hints. Rico Mariani Microsoft Corporation April 2003 Summary: The .NET garbage collector provides a high-speed allocation service with good use of memory and no long-term fragmentation problems. This article explains how garbage collectors work, then goes on to discuss some of the performance problems that might be encountered in a garbage-collected environment. (10 printed pages) Applies to: Microsoft® .NET Framework Contents Introduction Simplified Model Collecting the Garbage Performance Finalization Conclusion Introduction In order to understand how to make good use of the garbage collector and what performance problems you might run into when running in a garbage-collected environment, it's important to understand the basics of how garbage collectors work and how those inner workings affect running programs.

Simplified Model For explanatory purposes, consider the following simplified model of the managed heap. Figure 1. The rules for this simplified model are as follows: Collecting the Garbage. Better Design and Flexibility with Extreme Programming Techniques. Test-Driven C# Improve the Design and Flexibility of Your Project with Extreme Programming Techniques Will Stott and James Newkirk Code download available at:ExtremeProgramming.exe(127 KB) Wouldn't you just love to create code that becomes easier to work with as the project matures rather than more difficult?

It seems that no matter how much care you take, sooner or later, your code will become a maze. The bigger the project, the worse this problem gets. How many times have you started a project with a near-perfect design only to see it unravel once coding starts? Test-driven development (TDD) alters the process of writing code so that change is not only possible, but desirable. This cycle is repeated frequently, each time running all the tests in order to ensure that the product is kept in a working state. What makes TDD so effective is the automation of your programmer (unit) tests, and the great news is that the only tools you need are available for free on the Internet. Lessons Learned. Yun Jin's WebLog. Leaks.en.pdf (application/pdf Object) .NET Debugging Demos - Information and setup instructions - If broken it is, fix it you should. .NET Debugging Demos This is a series of debugging demos aimed to help you get some hands on experience in debugging the most common types of Hang/performance, memory and crash scenarios in .net applications.

The demos are written in ASP.NET which means that you do need IIS and .net framework 2.0 installed on the development machine where you install the demos. Each new demo will have a set of instructions on how to get started but the lab instructions are deliberately kept very brief in order to give you the most chance to explore on your own. Hints will be available for each demo in case you get stuck. New demos will be published on as time permits (I am planning to release one new lab per week). All demos will use the same web site so there is only one application to install for all demos. Installation 1. 2. 3. 4. 5. 6. 7. Terminology and tools Each demo/lab will assume that you are familiar with the following: Install Windbg Getting started - Part I Available Labs:

Inversion of Control Containers and the Dependency Injection pattern. In the Java community there's been a rush of lightweight containers that help to assemble components from different projects into a cohesive application. Underlying these containers is a common pattern to how they perform the wiring, a concept they refer under the very generic name of "Inversion of Control". In this article I dig into how this pattern works, under the more specific name of "Dependency Injection", and contrast it with the Service Locator alternative. The choice between them is less important than the principle of separating configuration from use.

One of the entertaining things about the enterprise Java world is the huge amount of activity in building alternatives to the mainstream J2EE technologies, much of it happening in open source. A lot of this is a reaction to the heavyweight complexity in the mainstream J2EE world, but much of it is also exploring alternatives and coming up with creative ideas. Components and Services A Naive Example class MovieLister... Understanding IoC Container - sfeldman.NET.

Thursday, February 14, 2008 10:58 PM Sean Feldman In a multi layered application architecture, loosely coupled code is more than a important. It's the basic which can either help the entire project progress, or drive it down the slope to the end (in the bad meaning of the word). One of the basics to keep coupling as low as possible is Inversion of Control (IoC) container.

I will try to show how to put in place a simple version of IoC container to allow loosely coupled design. The solution will contain several projects to emulate a layered application as much as possible. The choice of console application is only driven by intent to keep it as simple as possible. In our application we do basic logging at all layers. Public interface ILogger { void Log(string message); } Lets assume that the initial version of logger is implemented as a simple Console logger: public class ConsoleLogger : ILogger { public void Log(string message) { System.Console.WriteLine(message); } } 1: using Core; 25: return. Excellent tips to improve your Jquery programming-Part 2. In part-1 of this tutorial I told you about basics of jQuery usage. Now I will continue this tutorial with more awesome tips and tricks of jQuery programming. I hope you will love this tutorial like the first one. Learn to use animate properly When I first started using jQuery I loved the fact that it was easy to use the pre-defined animations like slideDown() and fadeIn() to get some really cool effects incredibly easy.

It's easy to take things further though because jQuery's animate() method is very easy to use and very powerful. The animate() method simply takes any CSS style and smoothly transitions it from one value to another. Unlike other jQuery functions, animations are automatically queued, so if you want to run a second animation once the first is finished then just call the animate method twice, no callback necessary.

If you want the animations to happen concurrently then just put both styles in the params object of a single call, like this... Learn about event delegation. How To: Use CLR Profiler. Wicked Code: UpdatePanel Tips and Tricks. XSS (Cross Site Scripting) Cheat Sheet. Create a new Fiddle - jsFiddle - Online Editor for the Web (JavaScript, MooTools, jQuery, Prototype, YUI, Glow and Dojo, HTML, CSS) Developer's Guide: Data API Protocol - YouTube APIs and Tools - Google Code. Code Playground. Web Performance Test Using Visual Studio- Part I.

TechTV.