background preloader

Technical Funda's

Facebook Twitter

6 important .NET concepts: - Stack, heap, Value types, reference types, boxing and Unboxing. 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. Exploring Session in ASP.Net. ViewState: Various ways to reduce performance overhead. Mastering Debugging in Visual Studio 2010 - A Beginner's Guide. URL Routing with ASP.NET 4.0. A Walkthrough to Application State. Maoni's WebLog. How to: Pass Values Between ASP.NET Web Pages.

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. The following options are available even if the source page is in a different ASP.NET Web application from the target page, or if the source page is not an ASP.NET Web Forms page: 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. Use session state.Create public properties in the source page and access the property values in the target page.Get control information in the target page from controls in the source page. Using a Query String When you use a hyperlink or Response.Redirect to navigate from one page to another, you can add information in a query string at the end of the URL. Note To use a query string to pass information Using Session State See Also. 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. Improving .NET Application Performance and Scalability J.D. Meier, Srinath Vasireddy, Ashish Babbar, and Alex Mackman Microsoft Corporation May 2004 Related Links Home Page for Improving .NET Application Performance and Scalability Chapter 5, Improving Managed Code Performance Send feedback to Scale@microsoft.com patterns & practices Library Summary: This How To shows you how to use the CLR Profiler tool to investigate your application's memory allocation profile.

Applies To CLR Profiler Contents OverviewDownloading CLR ProfilerWhat You Must KnowProfiling ApplicationsProfiling ASP.NET ApplicationsIdentifying Common Garbage Collection IssuesIdentifying Where Your Application Allocates MemoryAnalyzing Your Application's Allocation ProfileSample: ProfilerSample1Sample: ProfilerSample2Additional Resources Overview CLR Profiler enables you to look at the managed heap of a process and investigate the behavior of the garbage collector. CLR Profiler is not a starting point for analyzing problems. Step 1. Wicked Code: UpdatePanel Tips and Tricks. Wicked Code UpdatePanel Tips and Tricks Jeff Prosise For better or for worse, the UpdatePanel control is the darling of the ASP.NET AJAX community. I say "for better" because UpdatePanel makes partial-page rendering shockingly easy and "for worse" because its simplicity and ease-of-use come at the cost of efficiency and, ironically, bandwidth.

While UpdatePanel brings AJAX magic to ordinary Web pages, it doesn’t bring the efficiency we normally associate with AJAX. If you’re going to use an UpdatePanel control, you need to know what you’re getting in to. In addition, ASP.NET AJAX discussion forums are already filled with questions about customizing UpdatePanel. Now that ASP.NET AJAX has shipped, I’d like to examine UpdatePanel more closely—taking a close look at how you can customize it, optimize it, and even live without it. Update Highlighting Sometimes you can’t help but feel sorry for the developers at Microsoft.

_panels[i].set_visible(! Canceling UpdatePanel Updates Multiple UpdatePanels. XSS (Cross Site Scripting) Cheat Sheet. Last revision (mm/dd/yy): 07/4/2018 This cheat sheet lists a series of XSS attacks that can be used to bypass certain XSS defensive filters. Please note that input filtering is an incomplete defense for XSS which these tests can be used to illustrate. Basic XSS Test Without Filter Evasion This is a normal XSS JavaScript injection, and most likely to get caught but I suggest trying it first (the quotes are not required in any modern browser so they are omitted here): XSS Locator (Polygot) The following is a "polygot test XSS payload.

" javascript:/*--></title></style></textarea></script></xmp><svg/onload='+/"/+/onmouseover=1/+/[*/[]/+alert(1)//'> Image XSS using the JavaScript directive Image XSS using the JavaScript directive (IE7.0 doesn't support the JavaScript directive in context of an image, but it does in other contexts, but the following show the principles that would work in other tags as well: No quotes and no semicolon Case insensitive XSS attack vector HTML entities Malformed A tags <! <! 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. The YouTube Data API lets you incorporate functions normally executed on the YouTube website into your own website or application. The following sections identify the different types of resources that you can retrieve using the API. The API also supports methods to insert, update, or delete many of these resources. This reference guide explains how to use the API to perform all of these operations. The guide is organized by resource type. A resource represents a type of item that comprises part of the YouTube experience, such as a video, a playlist, or a subscription. Call the API The following requirements apply to YouTube Data API requests: Every request must either specify an API key (with the key parameter) or provide an OAuth 2.0 token. Resource types Activities An activity resource contains information about an action that a particular channel, or user, has taken on YouTube. For more information about this resource, see its resource representation and list of properties.

Captions Search. Code Playground. Web Performance Test Using Visual Studio- Part I. TechTV.