Thursday, August 25, 2005

Who process the aspx file ?

A web form has two files one is aspx and the other is .aspx.cs ( or aspx.cs ). When we compile an web Application the .aspx.cs converts into dll, (read MSIL )
After compilation we deploy the web App in the following way , copy the dll and the .aspx file into the target directory ( we copy the web.config , global.asax and the referenced dlls also, but please ignore these part for the time being )

When user request for a aspx page , IIS send the request to ASP.NET, and as the aspx pages are not MSIL, so it can not be processed by CLR, correct ? so , here is the confusion who process the aspx pages ? it's like this , when user hit a aspx page for the first time ASP.NET automatically generates a .NET class file that represents the page and compiles it to a second .dll file. The generated class for the .aspx page inherits from the code-behind class that was compiled into the project .dll file. This single .dll file is run at the server whenever the Web Forms page is requested. At run time, this .dll file processes the incoming request and responds by dynamically creating output and sending it back to the browser or client device.
Those who are familiar with ASP, the ASP.NET page framework model represents something new. The ASP model is one of HTML extended with script code. The ASP page consists of script code, such as (JScript, or VBScript) , coexisting with static HTML within the same file. The ASP parser reads the page, interprets it, and runs only the script code to get output results. ASP then merges the output of the script code with the static HTML output found in the page before sending the output back to the browser or client device. In the ASP.NET Page class model, the entire Web Forms page is, in effect, an executable program that generates output to be sent back to the browser or client device.

Monday, August 22, 2005

Last few days...

After quite sometime I am writing again .. I was not really tied up with events, but sometime you are just not in a mood to pen down anything.

Although I was not tied up with events, but I was part of couple of them staged last few days, let me start with Sandeep's marriage, we went to a place named Baharampur( quite far from Kolkata, it took 6 hours or so by bus) to attend his marriage, it was quite fun, then the reception party also went well, my handy-cam has caught all those precious moments.

Palash came from Hydrabad, stayed at my place for couple of days, we really had some nice time. We had a plan to go to Some place else one night, but ultimately couldn't make it.

Then I went to my brother's place on the independence day after a loooooong time, as usual lot of jhar/preaching on "why do you stay like this ?", "why do you go to bed so late ?" " why do you..... bla bla bla", after all these there was a grrrrrrand lunch( sometime I consider the food is enough for a whole week ). Now it's time for my chhoooo chweeet niece Barsha, she is still very young, still love to sit on laps rather than walking -:) I thought she will be talking to me this time, but she still talks in some unknown language( hahaha ), but overall it's really fun spending time with her.

Lastly something tragic, I have lost my mobile phone, ahhh. rather some body has stolen from my cot( hard to believe !!! ), and as usual people first doubt on the maid first, so did I, but later on I came to know from my land lady that it was an salesman who had stolen. anyway whoever it is .. I bought a new one( rather I had to buy one to survive), but I have lost all contact numbers of friends/relatives/corporate contacts, seems it will cause me trouble in coming days.

Saturday, August 06, 2005

Good luck friends

It was another Saturday night at someplace else, I was chilling with a beer and Floyd, suddenly I felt somebody yelled at me "hey buddy ... seems you wanna get pissed off with Floyd" ..., I saw a young lad holding his beer bottle in one hand and a cigarette in another looking at me with a brief smile. "Yeah man, that's the idea ... how about you ? ".. I yelled "same here" .. he replied back.
This is how I met my friend Sumit and then introduced to Shamik and Gilmore( so far I don't know his real name .. this chap is so freak .. he almost changed his name to Gilmore < David Gilmore is the lead guitarist of Floyd >) ). They are all IIT KGP, comp science guy .. passed out between 2002 - 04 , all of them got handsome job but none of them liked it and left their companies. All they said me that they are involved with some research oriented project with IIT KGP.

We used to meet in almost every Saturday at Someplace else and then we used to involve into very serious things ... ( as you guess )beer, rock n roll and pure adda.
Gilmore is hailed our friendship as "halusinative friendship". We had a nice mental setup, every body is freak about rock n roll and all of are crazy about the world of software.
Last Saturday Sumit broke the news( it's good as well as sad ) to me ... they all 3 are going to join MIT, and they will leave next month, it's a kind of dreams comes true situation, I felt so happy but the next moment I felt I will miss them for a long time, that made me lil sad , but all in all MIT keeps me high ... I am really proud of you my friends .. go and make a mark in life. kudos to Sumit, Shamik and Gilmore.

I must mention about one more friend named Cherry, last month she joined us as a trainee, I used eat up her brain a lot .. -:) , but I must admit she is very sharp...
All I knew she was doing some research and study on electronics here, she is not a rock-n-roll freak but loves music and one thing I like about her is she also hates hip-hop( I just can't tolerate this sound, all trash to me ), she is a true Indian ....we used to fight on whether India is better country India than Australia ...... she left few days back to join her college

In summery I am going to loose 4 friends( one already out of the horizon ) .. so it's a tough time ... but anyway .. this is life, people come into your life become friend, spend time with you and then disappear, but thanks to internet .. we will be in touch. Good wishes to all of them...

God kept some good news for me as well, Palash is coming to town to attend Sandeep's( another common pal ) marriage ceremony. Just few months back we had a small gang......... Palash, Sandeep, Amitava, Amit and myself ... we used to paint the city in RED and enjoy to the fullest. Now we are all parted, Palsh is in Hydrabad, Amitava and Amit is in Bangalore.
But god is kind enough to give us one more opportunity to get together again and taste the same fun once more. thank you god, I have no complain whatsoever.







Monday, August 01, 2005

& and && in C# - Part II

Revisiting & AND && operator, in the part I, I have talked about them and written a very short code snippet, in part II, I will discuss how we can write more useful code using these operators.
Consider we have to write a user control and it has several flags like( IsVissible, IsEditable, IsDraggable etc etc ), common practise is creating boolean variable for each flag, but we can get away with all boolean flags, using one single integer variable .. how ? let me explain it.

We will declare one integer variable ( say name it as m_AllFlags ) and each bit within m_AllFlags variable would represent the current state of one of the flags. we would then use bit manipulations to set and to get each flag.
First, we need to set up constants that indicate the various flags for our UC, these flags should each be a different power of 2 to ensure that each bit is used by only one flag. we will set bits of flags accordingly to the current state of each flag.

int flags = 0 ; ( means that all flags are false (none of the bits are set) )
const int TESTCONTROL_VISIBLE = 1;
const int TESTCONTROL_EDITABLE = 2;
now we will write property for each flags .. lets have a look at IsVisible property

public bool IsVisible
{
set
{
if( value )
{
m_AllFlags = m_AllFlags | TESTCONTROL_VISIBLE;
}
else
{
m_AllFlags = m_AllFlags ^ TESTCONTROL_VISIBLE;
}
}
get
{
if( (m_AllFlags & TESTCONTROL_VISIBLE) == TESTCONTROL_VISIBLE )
{
return true;
}
else
{
return false;
}
}
}

so if user send TRUE we will do a inclusive OR and if it is FALSE we will do exclusive OR, and at the time GET we will do a bitwise AND , if the returned value matches with the constant then we will return TRUE else FALSE. Those who are not yet familiar with inclusive/exclusive OR the following table will help you to understand the concept ..
The Bitwise Inclusive OR Function Bit in op1 Corresponding Bit in op2 Result
0 0 0
0 1 1
1 0 1
1 1 1
The Bitwise Exclusive OR (XOR) Function Bit in op1 Corresponding Bit in op2 Result
0 0 0
0 1 1
1 0 1
1 1 0

lets see what happen if caller pass TRUE to this property ...
m_AllFlags = m_AllFlags | TESTCONTROL_VISIBLE; [ m_AllFlags = 0 inclusive OR 1, so now m_AllFlags = 1 ]

now if caller does a GET the following line will execute ...
if( (m_AllFlags & TESTCONTROL_VISIBLE) == TESTCONTROL_VISIBLE ) it does a bitwise AND then compare the value with a constant, based on the comparison result it returns TRUE or FALSE,
For those are not yet familiar with bitwise AND .. please have a look at the following table ..
The Bitwise AND Function Bit in op1 Corresponding Bit in op2 Result
0 0 0
0 1 0
1 0 0
1 1 1
(m_AllFlags & TESTCONTROL_VISIBLE) == TESTCONTROL_VISIBLE ) [ 1 bitwiseAND 1 == 1 , hence it returns TRUE ]

Let us consider, after this caller set the flag as FALSE
m_AllFlags = m_AllFlags ^ TESTCONTROL_VISIBLE; [ m_AllFlags = 1 exclusive OR 1, so now m_AllFlags = 0 ]

now if we do a GET
(m_AllFlags & TESTCONTROL_VISIBLE) == TESTCONTROL_VISIBLE ) [ 0 bitwiseAND 1 == 1 , hence it returns FALSE ]

Most important point about the above code snippet is .. when the caller pass a flag value .. we need to first check the current bit value and if it is same we will just ignore it else we will set the value,[ if( (m_AllFlags & TESTCONTROL_VISIBLE) == TESTCONTROL_VISIBLE ) { //caller has passed the same value .. ignore it.} ].
So we can end up with one single int variable which will hold all the flags, I have uploaded the entire project code in this following location( Operator test source code )please download and play with it if you feel interested.

Note : Thanks to Palb for his comments.

Neo