Saturday 22 December 2012

How to Count Website Visitors in Asp.net


Hi Friends,
In this article i will tell you how to count total number of visitors in website by using simple 3 steps
This is a very simple website user counter to see how many people have visited a web page if you want to show it on a web page.

Step 1:  
 We can do this by using (or creating) a global.asax file.
Every time a session is started, you increment an integer, which holds the number of current visitors. Every time a session is ended, you subtract one from that integer. Next, you will have to use public properties for all pages to be able to retrieve the information.


public class Global : System.Web.HttpApplication
{
    private static int totalNumberOfUsers = 0;
    private static int currentNumberOfUsers = 0;

        protected void Application_Start(object sender, EventArgs e)
    {
        // Code that runs on application startup
       totalNumberOfUsers = 0;
    }


    protected void Session_Start(Object sender, EventArgs e)
    {
        // Code that runs when a new session is started
      totalNumberOfUsers += 1;
      currentNumberOfUsers += 1;
    }
    protected void Session_End(Object sender, EventArgs e)
    {
        // Code that runs when a session ends.
        // Note: The Session_End event is raised only when the sessionstate mode
       // is set to InProc in the Web.config file. 
        //If session mode is set to   StateServer
        // or SQLServer, the event is not raised.

      currentNumberOfUsers -= 1;
    }
    protected void Application_End(Object sender, EventArgs e)
    { }

    public static int TotalNumberOfUsers{ get { return totalNumberOfUsers; } }
    public static int CurrentNumberOfUsers{ get { return currentNumberOfUsers; } }
}

Step 2:  

Next, in your control, set the values of the global.asax file in the right labels.
private void Page_Load(object sender, System.EventArgs e)
{
  int currentNumberOfUsers = HitCounters.Global.CurrentNumberOfUsers;
  int totalNumberOfUsers = HitCounters.Global.TotalNumberOfUsers;
  lblCurrentNumberOfUsers.Text = currentNumberOfUsers.ToString();
  lblTotalNumberOfUsers.Text = totalNumberOfUsers.ToString();
}


Step 3:  

   In order for this to work correctly we need to enable sessionstate and configure its mode to InProc value (in our web.config file):

        <system.web>
        <sessionState mode="InProc" cookieless="false" timeout="20" />
        </system.web>

In-process mode stores session state values and variables in memory on the local Web server. 
It is the only mode that supports the Session_OnEnd event that we used previously.

Timeout value (in minutes, not in seconds) configures how long our sessions are kept 'alive' - in other words
here we set how long our users can be inactive before considered Offline.

In this example timeout is set to 20 minutes, so while our visitors click on some links in our website at least once
in a 20 minutes, they are considered online.



Happy Programming!!

Don’t forget to leave your feedback and comments below!

If you have any query mail me to Sujeet.bhujbal@gmail.com     


Regards

Sujeet Bhujbal

Wednesday 19 December 2012

What’s new in Visual Studio 2012


What’s new in Visual Studio 2012

Hi Friends,
Yesterday I install the newest version of Visual Studio which is Visual Studio 2012. The new Visual Studio 2012 family of products includes the commercial Visual Studio 2012 Professional, Premium, Ultimate and the Team Foundation Server 2012.

Following are some of the new features available with this new release of Visual Studio 2012.
  • User Interface - The User Interface is slightly different when compared to previous versions of Visual Studio.

 

User Interface

  • Windows 8 Metro Style Applications - Can create Windows 8 Metro Style applications and this is one of most featured things in Visual Studio 2012 and not to mention it is one of things I am missing in Visual Studio 2010.
  • LightSwitch - LightSwitch for Visual Studio 2012 – Previously Microsoft Visual Studio LightSwitch was a separate product and with the new Visual Studio 2012, it is included in default.
LightSwitch

  • Solution Explorer - Now with the new Solution Explorer we can browse our project’s objects and drill down into methods and properties. It also gives us the ability to search and preview files, objects and external items.
Solution Explorer

  • SQL Server Object Explorer - With previous versions of Visual Studio we couldn’t manage objects in instances of the Database Engine through Visual Studio. Now with the newly introduced SQL Server Object Explorer, it gives us same feeling as using the Object Explorer in SQL Server Management Studio.
SQL Server Object Explorer

  • IIS Express - Previous versions of Visual Studio used its own ASP.NET Development Server as the default web server for locally running and testing web applications. Visual Studio 2012 uses IIS Express as the default local web server. But of course you can change it anytime.
IIS Express

  • Debugging Browser - Visual Studio gives us another nice feature which is, now we can select the browser to debug/browse our web application. For example if your default browser is Google Chrome, your web application will be debugged using Google Chrome in default. But if you are debugging a Silverlight application you specifically need Internet Explorer. Now we don’t have to change the default browser, we only have to change debugging browser.
Debugging Browser




Happy Programming!!

Don’t forget to leave your feedback and comments below!

If you have any query mail me to Sujeet.bhujbal@gmail.com     


Regards

Sujeet Bhujbal

Monday 19 November 2012

Preparation for Exam 70-503

Preparation for Exam 70-503

 Microsoft .NET Framework 3.5 – Windows Communication Foundation Application Development


Introduction

In the last week I had given MCTS paper 70-503 for WCF. I cleared this exam with good score.
I am giving some inputs for how to prepare for exam
The exam consists of 43 questions and is scheduled for 140 min. You'll not find any exam simulator for this exam at this time as far as I know, so if you wish to prepare for the exam just get some hands on experience and study the books.




After finishing the exam, I got the idea how to score good in that exam - ABC: Address, binding and contract. If you have solid understanding in these three pillars of WCF – you will surely score well. 


Syllabus

These are the topic where you should have solid understanding before sitting for the exam –
1.           WCF service and client configuration – not using service configuration tool provided in windows sdk , rather thorough Xml.
2.           Security related configuration – Authentication and Authorization support in WCF thorough xml configuration.
3.           Service Instance – Single ,PerCall , PerSession and Thread-safety of the instance.
4.           Session and Transaction.
5.           Duplex channel.  WsDualHttpBinding.
6.           Serialization.
7.           Instrumentation of WCF service instance.
8.           Interoperability with ASMX.
9.           Creating Services
10.       Exposing and Deploying Services
11.       Instrumenting and Administering Services
12.       Consuming Services
13.       Securing Services
14.       Managing the Service Life Cycle 


I have so many dumps for 70-503 Exam... But first study from Microsoft Study material then give the exam

if you want a study material mail me sujeet.bhujbal@gmail.com

Books Reference links





Happy Programming ! !

If you have any query mail me to Sujeet.bhujbal@gmail.com     


Regards

Sujeet Bhujbal

------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------