Classic mode and Integrated mode in IIS


Classic mode (the only mode in IIS6 and below) is a mode where IIS only works with ISAPI extensions and ISAPI filters directly. In fact, in this mode, ASP.NET is just an ISAPI extension (aspnet_isapi.dll) and an ISAPI filter (aspnet_filter.dll). IIS just treats ASP.NET as an external plugin implemented in ISAPI and works with it like a black box (and only when it's needs to give out the request to ASP.NET). In this mode, ASP.NET is not much different from PHP or other technologies for IIS.

Integrated mode, on the other hand, is a new mode in IIS7 where IIS pipeline is tightly integrated (i.e. is just the same) as ASP.NET request pipeline. ASP.NET can see every request it wants to and manipulate things along the way. ASP.NET is no longer treated as an external plugin. It's completely blended and integrated in IIS. In this mode, ASP.NET HttpModules basically have nearly as much power as an ISAPI filter would have had and ASP.NET HttpHandlers can have nearly equivalent capability as an ISAPI extension could have. In this mode, ASP.NET is basically a part of IIS.

Delegate and Method


I have a delegate and a method. what are the steps to call that method (give technical steps)

  1. Create a delegate
  2. Create a function matching the signature as per the delegate or vice-versa
  3. Assign method to the delegate instance
  4. Call delegate function

The entire code looks like,




 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
class Program
    {
        public delegate int MYDelegate(int x, int y);

        static void Main(string[] args)
        {
            MYDelegate d = AddNumbers;
            Console.WriteLine(d(20, 30).ToString());
            Console.ReadLine();
        }

        public static int AddNumbers(int a, int b)
        {
            return (a + b);
        }
    }

Implementing Singleton Design Pattern using C#

Hello friends,

All of you must be aware of what Singleton Design Pattern is. Just to define it in one line, It is a pattern which allows creation of one and only instance of a class. 

The practical scenario where you can go with this pattern is having a print job class instance, single running instance of an application etc. 

The best example is Google Talk desktop application.
Let us try to implement this pattern via C# code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DesignPatternsDemo
{
    public class SingletonClass
    {
        private SingletonClass()
        {
        }

        //Implementation #1
        //static SingletonClass _instance = null;
        //public static SingletonClass GetInstance()
        //{
        //    if (_instance == null)
        //    {
        //        _instance = new SingletonClass();
        //    }
        //    return _instance;
        //}

        //Implementation #2
        //Be aware that in a multithreaded program, different threads could try
        //to instantiate a class simultaneously. For this reason, a Singleton
        //implementation that relies on an if statement to check whether the
        //instance is null will not be thread-safe. Do not use code like that!

        static readonly SingletonClass _instance = new SingletonClass();

        public static SingletonClass GetInstance
        {
            get
            {
                return _instance;
            }
        }

        public string GetWelcomeMessage()
        {
            return "Welcome to the Singleton world!! ";
        }
    }
}

The Singleton class above will be instantiated only once.
When the GetInstance is called, it will return the statically created instance of the class.

ASP.Net Page Life Cycle

Hello friends,

I know this information is easily available over the net. However I just thought to share it on my blog just for quick reference. Here I have written ASP.Net page life cycle events in an order of there execution with one liner explanation.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
public partial class Home : System.Web.UI.Page
    {
        protected void Page_PreInit(object sender, EventArgs e)
        {
            //Initialize themes, master page, profile properties
            //check IsPostBack, cross-page postbacks
            System.Diagnostics.Trace.WriteLine("Inside Page_PreInit");
        }

        protected void Page_Init(object sender, EventArgs e)
        {
            //Initialize or read control properties here
            System.Diagnostics.Trace.WriteLine("Inside Page_Init");
        }

        protected void Page_InitComplete(object sender, EventArgs e)
        {
            // Changes to ViewState that you want in next postback
            System.Diagnostics.Trace.WriteLine("Inside Page_InitComplete");
        }

        protected void Page_PreLoad(object sender, EventArgs e)
        {
            //Raised when page loads ViewState for itself and controls
            System.Diagnostics.Trace.WriteLine("Inside Page_PreLoad");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            //Set control properties, initiate Database connections
            System.Diagnostics.Trace.WriteLine("Inside Page_Load");
        }

        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            //tasks that require that all other controls on the page be loaded.
            System.Diagnostics.Trace.WriteLine("Inside Page_LoadComplete");
        }

        protected void Page_Prerender(object sender, EventArgs e)
        {
            //to make final changes to the contents of the page or its
            //controls before the rendering stage begins
            System.Diagnostics.Trace.WriteLine("Inside Page_Prerender");
        }
        protected void Page_PrerenderComplete(object sender, EventArgs e)
        {
            //Raised after each data bound control whose 
            //DataSourceID property is set calls its DataBind method.
            System.Diagnostics.Trace.WriteLine("Inside Page_PrerenderComplete");
        }
        protected void Page_SaveStateComplete(object sender, EventArgs e)
        {
            //Raised after view state and control state have been saved for the page and for all controls.
            //Any changes to the page or controls at this point affect rendering, but the changes will not be retrieved on the next postback
            System.Diagnostics.Trace.WriteLine("Inside Page_SaveStateComplete");
        }
        protected void Page_Render(object sender, EventArgs e)
        {
            //This is not an event; instead, at this stage of processing, the Page object calls this method on each control
            System.Diagnostics.Trace.WriteLine("Inside Page_Render");
        }
        protected void Page_Unload(object sender, EventArgs e)
        {
            //Raised for each control and then for the page.
            //During the unload stage, the page and its controls have been rendered, so you cannot make further changes to the response stream. 
            //If you attempt to call a method such as the Response.Write method, the page will throw an exception.
            System.Diagnostics.Trace.WriteLine("Inside Page_Unload");
            //Response.Write("This is not allowed");
        }
    }

Labels

.net .Net Instrumentation logging .net localization Agile amazon amazon elasticache amazon services AppDomain Application Domain architecture asp ASP.Net authentication authentication mechanisms Byte order mark c# cache canvas app cdata certifications class classic mode cloud cloud computing cluster code-behind Combobox compilation Configuration providers configurations connection connectionString constructors control controls contructor CSV CTS .net types conversion database DataGridView DataSource DataTable DataType DBML delegates design pattern dispose double encoding Entity framework Events exception handling expiry fault contracts fault exceptions function pointers functions generics help HostingEnvironmentException IIS inner join instance management integrated mode javascript join left outer join LINQ LINQ join LINQ to SQL memory leak methods microsoft model driven app modes in IIS MSIL multiple catch blocks no primary key Nullable Osmos Osmotic Osmotic communication Osmotic communications page events page life cycle partial class PMI powerapps preserve precision points private contructor ProcessExit Project management properties property protect connectionString providerName providers query regular expression repository Responsive Web Design return type run-time RWD Saas self join session session expiry sessions singelton singleton pattern software as a service source control system SQLMetal string time management time-boxing toolstrip ToolStrip controls ToolStripControlHost tortoise SVN ToString() try catch finally update wcf web application web design web site web.config where-clause xml

Pages