Windows Server 2008 and IIS 7.0 RCO available for download

Hi,

As the title of the post says the season of the RCO has started at the world of Microsoft.

Continued...

Asp.Net and Session – some Interesting Facts

Hi,

Yesterday I was discussion with my colleagues about session and a few interesting things popped up. So I thought I would share the same with all.

If we have the session state enabled and we do not store anything in the session then the session Id will change every time a new request is made. This also means that a new session is created every time. But the sate is never saved as there is nothing to save. Note the session_Start event will not fire for every request. The session_start event will only fire once.

Another interesting stuff about session Id is that it does not changes after we have called the Session.Abondon() method or when the session times out. Even though Session State expires but the session ID remains same. The session Id will last as long as the browser session does.

Continued...

Using the Take and Skip Keyword to reduce the number of records fetched in the Query

Hi,

One of the nicest things LINQ makes easy is paging. LINQ seems to de basic paging query out of the box. Paging is well built in LINQ and is very very easy to be used.

With LINQ we no longer have to right those complex logic just to create paging effect. The two mainly keyword mainly used for paging in LINQ framework are Take and Skip.

The Take keyword is used to decide how many records are to be fetched. A simple example of the Take keyword is provided below.

List<Customer> customers = GetCustomerList();
 
    var first3Customers = (
                from c in customers

Continued...

Some more Lambda expression

Hi,

Continuing with my work on different Lambda expression. Here are some more Lambda’s that I wrote (when I was practicing them).

You can get my previous example here
http://www.vikramlakhotia.com/Starting_with_the_basic_of_Lambda_Expression.aspx
http://www.vikramlakhotia.com/Some_examples_on_how_to_use_Lambda_Expression.aspx
http://www.vikramlakhotia.com/Using_Lambda_expressions_in_LINQ.aspx

To get the first record matching certain condition in the list

string strVal = SomesTringCollection.First(str => str[0] == 'V');

As you would have guessed to get the last record we have a Last method

Continued...

Using the Begin Invoke method to update the values in other thread

Hi,

Many a times when we are working with multi threaded situation, we want to update the value of another thread from the same. Let say you are working on a windows application which creates a new thread to process some work. Now you want to update the status of work in a label in a windows application.

If you try and update the label’s text property from another thread then you will get a runtime exception. As the other thread cannot access this class variable.

To work around this we have to use the BeginInvoke method to queue the message to the proper thread. Here is the code on how to update a label in a multi threaded environment.

    private delegate void SetLabel1Textdel(string someText);

    private void UpdateLabel1Text(string someText)

    {

Continued...

Using PerformanceCounter class to find the CPU Usage of a given Process

Hi,

Yesterday I was sitting idle and trying to write some dummy windows application. Suddenly I saw that my application is using a lot of CPU resource.

But what if I wanted to know the CPU Usage of an application without using the task manager. Well what if you wanted to show the CPU usage of the current Application to the user. Well I searched a bit and got the answer. So I thought I would share the code with all.

Here is the code for showing the CPU Usage by all the currently running application.
foreach (Process process in Process.GetProcesses())

            {

Continued...

string.compare and string.Equals the difference in usage of culture

Hi

In the string class we have 2 methods to compare the string. I see most of the developers get confused between the 2. Both string.Compare and string.Equals methods are used for string comparison but they significant difference between them. The use of wrong method can lead to globalization and security issues.

String.Equals perform an ordinal comparison while string.Compare performs a culture sensitive comparison.

Continued...

Working with different path in the Request Object in Asp.Net

Hi,

When we are working on an asp.net Application we have to work with various type of Path. These paths are present in the Request Object. Each path has a different meaning and way for representation. Here is a list of different kind of paths used in Asp.net

Application Path – Will return the root path of the application. This is used to get the application path. This can be found in Request Object. By the default the

CurrentExecutionFilePath – used to get the virtual path of the current request. The difference from the FilePath property is that if there is a redirection of the request in the server code (Server.Transfer) then this will return the correct value. For example it might return the value /Vikramlakhotia.com/MyAdm/LogFeed.aspx

FilePath – will provide the Virtual Path of the current request. (See the difference with CurrentExecutionFilePath above.)

Continued...

Asp.Net Web Application different file types

Hi,

A web site Application can have multiple files of multiple file type. Many of these are managed by Asp.Net and many by IIS itself. File types that are managed by the Asp.Net are mapped to AspNet_isapi.dll in IIS. The file types that are not mapped to AspNet_isapi.dll are not managed by asp.net but by IIS only.

Here is a list of all the file types that are managed by Asp.Net.

.asax – The common most example is the Global.asax file. This normally contains code that is derived from HttpApplication class. The file contains application level event that are raised by application like Application start, application end etc. The file has to be kept in the root folder of the application.

.ascx – This file type is used to create web user control. The file can reside in either root folder on in a sub-directory.

.ashx – The file type is used to create generic handler by implementing the IHttpHandler interface.

Continued...

Working with array item in JavaScript

Hi,

Last day I was working with the some JavaScript and array. I was basically working with adding and deletion of the array item. In JavaScript we can add and delete Items in the array in the following way. 

               var exmapleArray = new Array("a", "b");

To add item at the end of the array we use the push method of the array object.

               exmapleArray.push("c"); 1

Continued...

Working with LINQ and Lambda expressions

Hi,

Continuing on my post on Lambda and LINQ, in this post I will talk about how to use the lambda expression in the LINQ query. LINQ query can work great without the Lambda expression. But we can also use Lambda expression in the LINQ query.

Continued...
 
Copyright © 2006 - 2008 Vikram Lakhotia