Wednesday, April 13, 2011

Google talk takes high CPU or frozen running with winamp

First i would like to say that this problem is coming because of showing your current music on google talk with winamp. I faced this problem and during research i found this problem was coming because of the showing current music track on google talk, and now you can fix this problem by two different ways

First:- Changes your current status with some new status ( but i am not sure this will work for all because some time google talk frozen and you will not able to change current status), so now you can try

second option
Copy the winamp.m3u file from c:\Documents and Settings\<username>\Application Data\Winamp\ to c:\Program Files\Winamp\
this will solve your problem instantly, Hope this work for all.
If this work please send our comment.

Saturday, April 2, 2011

Buying shares for the first time

1. Get a broker

People like you and me cannot just go to a stock exchange and buy and sell shares.

Only the members of the stock exchange can. These members are called brokers and they buy and sell shares on our behalf.

So, if you want to start investing in shares, you can do it only through a broker.

Every stockbroker has to be registered with the Securities and Exchange Board of India [Images ], which is the stock market regulator.

You can either choose a broker (who is directly registered with SEBI) or a sub-broker (people licensed by brokers to work under them).

The Bombay Stock Exchange directory or the National Stock Exchange Web site will give you a list of brokers affiliated to them. Most of them entertain retail clients.

If you want an online broker, you can start by looking at the Web sites of some well-known online players:Sharekhan, Kotak Securities, ICICI Direct, 5paise and India Bulls.

2. Get a demat account

Gone are the days when shares were held as physical certificates.

Today, they are held in an electronic form in demat accounts.

Demat refers to a dematerialised account.

Let's say your portfolio of shares looks like this: 40 shares of Infosys [ Get Quote ], 25 of Wipro [ Get Quote ], 45 of HLL [ Get Quote ] and 100 of ACC.

They will show in your demat account. You don't have to possess any physical certificates showing you own these shares. They are all held electronically in your account.

Periodically, you will get a demat statement telling you what shares you have in your demat account.

How to get a demat account

To get a demat account, you will have to approach a Depository Participant.

A depository is a place where an investor's stocks are held in electronic form.

There are only two depositories in India -- the National Securities Depository Ltd and the Central Depository Services Ltd.

The depository has agents who are called Depository Participants. In India, there are over a hundred DPs.

Think of it like a bank. The head office, where all the technology rests and the details of all the accounts are held, is like the depository. The DPs are like the branches of banks that cater to individuals.

A broker, however, is not similar to a DP. A broker is a member of the stock exchange and he buys and sells shares for his clients and for himself. A DP, on the other hand, gives you an account where you can hold those shares.

To get a list of the registered DPs, visit the NSDL and CDSL Web sites.

3. Get a PAN

The taxman demands that you get yourself a Permanent Account Number.

This is a unique 10-digit alphanumeric number (AABPS1205E, for example) that identifies and tracks an individual in the taxman's database.

Almost every money transaction demands the use of a PAN. These include:

~ When you get a job

~ When you file an income tax return

~ When you open a bank account

~ When you deposit cash of Rs 50,000 or more in a bank

~ When you open a bank fixed deposit of Rs 50,000 or more

~ When you open a post office deposit of Rs 50,000 or more

~ When you buy/ sell shares and mutual funds

~ When you buy/ sell property

~ When you buy a vehicle

~ When you take a loan: home/ personal/ other

~ When you install a telephone (or buy a cell phone)

~ When you pay in cash to hotels and restaurants against bills for an amount exceeding Rs 25,000 at a time

~ You also need to mention it in every transaction you have with the tax officials.

If you are going through a tax consultant, you need not worry. He will supply you with Form 49A (the application form for the PAN number) and give you a list of the documents he needs.

However, if you believe in doing things on your own, the process is really not that tedious.

You could visit the official Web sites of the Income Tax department or UTI Investor Services Ltd or National Securities Depository Limited

Download Form 49A from any of these sites and follow the instructions.

You should get your PAN in the form of a laminated card within a month.

4. Check if you need a UIN

This depends on how much you plan to invest.

The Unique Identification Number is the identification an investor needs to buy and sell shares or mutual fund units.

It is part of the Security and Exchange Board of India's attempt to create a database of all Market Participants and Investors, called MAPIN.

Who needs a UIN?

An investor who is involved in a single transaction of Rs 1,00,000 or more will have to quote his/ her UIN.

If you plan to be a prominent stock market player or a mutual fund investor and expect to deal with such huge amounts in the near future, you should get a UIN.

SEBI has appointed the National Securities Depositories Ltd that, in turn, has appointed Points Of Service agents. The NSDL Web site has a list of the POS agents.

Visit the office of a POS agent. Make sure you take an appointment before you go. As part of the application process, your fingerprints will be scanned and a photograph taken.

All you have to do is fill and submit an application form (there are separate forms for corporates and individuals). You can also download the form for an individual at the NSDL Web site. 

Incidentally, the UIN is totally different from a PAN. The Permanent Account Number is an identification number for filing your income tax returns.

Thursday, March 10, 2011

firefox Change Address Bar Search Provider

When Firefox performs a search from the Address Bar, it queries the search engine string you have setup within Firefox. If it’s using Yahoo, you can switch to Google. Don’t like Google? Use Ask. Here’s how to switch which search engine Firefox searches when you use the address bar to search.

1. In Firefox type about:config in the address bar and press ENTER.

2. Locate and double-click the entry for keyword.URL

3.  Set the value based on which search provider you would like to use for your address bar searches. Here are a few search strings you can use.

Yahoo: http://search.yahoo.com/search?p=

Ask: http://www.ask.com/web?q=

Google: http://www.google.com/search?&q=

ChaCha: http://search.chacha.com/search/query?searchwithguide=0&query=

Tuesday, February 15, 2011

Accessing WCF Services from Other Domains

WCFAccessing Services from Other Domains

In the previous example, the web service was on the same domain as your Silverlight application. What if
you want to call a service that is on a different domain?
In fact, as a best practice, it is preferred to have your web services stored on a domain separate from
your web application. Even for applications where you control both the web service and the Silverlight
application, you may be dealing with different domains.
If you attempt to access a service from a different domain in Silverlight, you will notice that it fails.
This is because, by default, a Silverlight application cannot call services that are on a different domain,
unless it is permitted to do so by the service host. In order for Silverlight to determine if it has permission
to access a service on a certain domain, it will look for one of two files in the root of the target domain:
clientaccesspolicy.xml or crossdomain.xml.
First, Silverlight will look for a file named clientaccesspolicy.xml in the domain’s root. This is
Silverlight’s client-access policy file. If you are publishing your own services that you want to be
accessible by Silverlight applications, this is the file that you want to use, as it provides the most options
for Silverlight application policy permissions. The following is a sample clientaccesspolicy.xml file:

<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>

The important elements are <allow-from> and <grant-to>. The <allow-from> element defines which
domains are permitted to access the resources specified in the <grant-to> element.
If Silverlight cannot find a clientaccesspolicy.xml file at the root of the domain from which you are
attempting to access a service, it will then look for a file named crossdomain.xml in the root. This is the
XML policy file that has been used to provide access for Flash applications to access cross-domain
services, and Silverlight supports this file as well. The following is an example of a crossdomain.xml file:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy
SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

Again, even though Silverlight supports crossdomain.xml, using clientaccesspolicy.xml for
Silverlight applications is the preferred and best practice.

Sunday, February 6, 2011

ASP.NET Application Life Cycle with IIS Web Server

Introduction

In this article, we will try to understand what happens when a user submits a request to an ASP.NET web app. There are lots of articles that explain this topic, but none that shows in a clear way what really happens in depth during the request. After reading this article, you will be able to understand:
  • What is a Web Server
  • HTTP - TCP/IP protocol
  • IIS
  • Web communication
  • Application Manager
  • Hosting environment
  • Application Domain
  • Application Pool
  • How many app domains are created against a client request
  • How many HttpApplications are created against a request and how I can affect this behaviour
  • What is the work processor and how many of it are running against a request
  • What happens in depth between a request and a response

Start from scratch

All the articles I have read usually begins with "The user sends a request to IIS... bla bla bla". Everyone knows that IIS is a web server where we host our web applications (and much more), but what is a web server?
Let start from the real beginning.
A Web Server (like Internet Information Server/Apache/etc.) is a piece of software that enables a website to be viewed using HTTP. We can abstract this concept by saying that a web server is a piece of software that allows resources (web pages, images, etc.) to be requested over the HTTP protocol. I am sure many of you have thought that a web server is just a special super computer, but it's just the software that runs on it that makes the difference between a normal computer and a web server.


As everyone knows, in a Web Communication, there are two main actors: the Client and the Server.
The client and the server, of course, need a connection to be able to communicate with each other, and a common set of rules to be able to understand each other. The rules they need to communicate are called protocols. Conceptually, when we speak to someone, we are using a protocol. The protocols in human communication are rules about appearance, speaking, listening, and understanding. These rules, also called protocols of conversation, represent different layers of communication. They work together to help people communicate successfully. The need for protocols also applies to computing systems. A communications protocol is a formal description of digital message formats and the rules for exchanging those messages in or between computing systems and in telecommunications.


HTTP knows all the "grammar", but it doesn't know anything about how to send a message or open a connection. That's why HTTP is built on top of TCP/IP. Below, you can see the conceptual model of this protocol on top of the HTTP protocol:


TCP/IP is in charge of managing the connection and all the low level operations needed to deliver the message exchanged between the client and the server.
In this article, I won't explain how TCP/IP works, because I should write a whole article on it, but it's good to know it is the engine that allows the client and the server to have message exchanges.
HTTP is a connectionless protocol, but it doesn't mean that the client and the server don't need to establish a connection before they start to communicate with each other. But, it means that the client and the server don't need to have any prearrangements before they start to communicate.
Connectionless means the client doesn't care if the server is ready to accept a request, and on the other hand, the server doesn't care if the client is ready to get the response, but a connection is still needed.
In connection-oriented communication, the communicating peers must first establish a logical or physical data channel or connection in a dialog preceding the exchange of user data.
Now, let's see what happens when a user puts an address into the browser address bar.
  • The browser breaks the URL into three parts:
  • The browser communicates with a name server to translate the server name "www.Pelusoft.co.uk" into an IP address, which it uses to connect to the server machine.
  • The browser then forms a connection to the server at that IP address on port 80. (We'll discuss ports later in this article.)
  • Following the HTTP protocol, the browser sents a GET request to the server, asking for the file "http://www.pelusoft.co.uk.com/index.htm". (Note that cookies may be sent from the browser to the server with the GET request -- see How Internet Cookies Work for details.)
  • The server then sents the HTML text for the web page to the browser. Cookies may also be sent from the server to the browser in the header for the page.)
  • The browser reads the HTML tags and formats the page onto your screen.


The current practice requires that the connection be established by the client prior to each request, and closed by the server after sending the response. Both clients and servers should be aware that either party may close the connection prematurely, due to user action, automated time-out, or program failure, and should handle such closing in a predictable fashion. In any case, the closing of the connection by either or both parties always terminates the current request, regardless of its status.
At this point, you should have an idea about how the HTTP - TCP/IP protocol works. Of course, there is a lot more to say, but the scope of this article is just a very high view of these protocols just to better understand all the steps that occur since the user starts to browse a web site.
Now it's time to go ahead, moving the focus on to what happens when the web server receives the request and how it can get the request itself.
As I showed earlier, a web server is a "normal computer" that is running a special software that makes it a Web Server. Let's suppose that IIS runs on our web server. From a very high view, IIS is just a process which is listening on a particular port (usually 80). Listening means it is ready to accept a connections from clients on port 80. A very important thing to remember is: IIS is not ASP.NET. This means that IIS doesn't know anything about ASP.NET; it can work by itself. We can have a web server that is hosting just HTML pages or images or any other kind of web resource. The web server, as I explained earlier, has to just return the resource the browser is asking for.


ASP.NET and IIS

The web server can also support server scripting (as ASP.NET). What I show in this paragraph is what happens on the server running ASP.NET and how IIS can "talk" with the ASP.NET engine. When we install ASP.NET on a server, the installation updates the script map of an application to the corresponding ISAPI extensions to process the request given to IIS. For example, the "aspx" extension will be mapped to aspnet_isapi.dll and hence requests for an aspx page to IIS will be given to aspnet_isapi (the ASP.NET registration can also be done using Aspnet_regiis). The script map is shown below:

The ISAPI filter is a plug-in that can access an HTTP data stream before IIS gets to see it. Without the ISAPI filter, IIS can not redirect a request to the ASP.NET engine (in the case of a .aspx page). From a very high point of view, we can think of the ISAPI filter as a router for IIS requests: every time there is a resource requested whose file extension is present on the map table (the one shown earlier), it redirect the request to the right place. In the case of an .aspx page, it redirects the request to the .NET runtime that knows how to elaborate the request. Now, let's see how it works.
When a request comes in:
  • IIS creates/runs the work processor (w3wp.exe) if it is not running.
  • The aspnet_isapi.dll is hosted in the w3wp.exe process. IIS checks for the script map and routes the request to aspnet_isapi.dll.
  • The request is passed to the .NET runtime that is hosted into w3wp.exe as well.

Finally, the request gets into the runtime

This paragraph focuses on how the runtime handles the request and shows all the objects involved in the process.
First of all, let's have a look at what happens when the request gets to the runtime.
  • When ASP.NET receives the first request for any resource in an application, a class named ApplicationManager creates an application domain. (Application domains provide isolation between applications for global variables, and allow each application to be unloaded separately.)
  • Within an application domain, an instance of the class named Hosting Environment is created, which provides access to information about the application such as the name of the folder where the application is stored.
  • After the application domain has been created and the Hosting Environment object instantiated, ASP.NET creates and initializes core objects such as HttpContext, HttpRequest, and HttpResponse.
  • After all core application objects have been initialized, the application is started by creating an instance of the HttpApplication class.
  • If the application has a Global.asax file, ASP.NET instead creates an instance of the Global.asax class that is derived from the HttpApplication class and uses the derived class to represent the application.
Those are the first steps that happens against a client request. Most articles don't say anything about these steps. In this article, we will analyze in depth what happens at each step.
Below, you can see all the steps the request has to pass though before it is elaborated.

Application Manager

The first object we have to talk about is the Application Manager.
Application Manager is actually an object that sits on top of all running ASP.NET AppDomains, and can do things like shut them all down or check for idle status.
For example, when you change the configuration file of your web application, the Application Manager is in charge to restart the AppDomain to allow all the running application instances (your web site instance) to be created again for loading the new configuration file you may have changed.
Requests that are already in the pipeline processing will continue to run through the existing pipeline, while any new request coming in gets routed to the new AppDomain. To avoid the problem of "hung requests", ASP.NET forcefully shuts down the AppDomain after the request timeout period is up, even if requests are still pending.
Application Manager is the "manager", but the Hosting Environment contains all the "logic" to manage the application instances. It's like when you have a class that uses an interface: within the class methods, you just call the interface method. In this case, the methods are called within the Application Manager, but are executed in the Hosting Environment (let's suppose the Hosting Environment is the class that implements the interface).
At this point, you should have a question: how is it possible the Application Manager can communicate with the Hosting Environment since it lives in an AppDomain? (We said the AppDomain creates a kind of boundary around the application to isolate the application itself.) In fact, the Hosting Environment has to inherit from the MarshalByRefObject class to use Remoting to communicate with the Application Manager. The Application Manager creates a remote object (the Hosting Environment) and calls methods on it :-)
So we can say the Hosting Environment is the "remote interface" that is used by the Application Manager, but the code is "executed" within the Hosting Environment object.

HttpApplication

On the previous paragraph, I used the term "Application" a lot. HttpApplication is an instance of your web application. It's the object in charge to "elaborate" the request and return the response that has to be sent back to the client. An HttpApplication can elaborate only one request at a time. However, to maximize performance, HttpApplication instances might be reused for multiple requests, but it always executes one request at a time.
This simplifies application event handling because you do not need to lock non-static members in the application class when you access them. This also allows you to store request-specific data in non-static members of the application class. For example, you can define a property in the Global.asax file and assign it a request-specific value.
You can't manually create an instance of HttpApplication; it is the Application Manager that is in charge to do that. You can only configure what is the maximum number of HttpApplications you want to be created by the Application Manager. There are a bunch of keys in the machine config that can affect the Application Manager behavior:
http://www.codeproject.com/images/minus.gifCollapse
<processModel enable="true|false"
    timeout="hrs:mins:secs|Infinite" 
    idleTimeout="hrs:mins:secs|Infinite"
    shutdownTimeout="hrs:mins:secs|Infinite"
    requestLimit="num|Infinite"
    requestQueueLimit="num|Infinite"
    restartQueueLimit="num|Infinite"
    memoryLimit="percent"
    webGarden="true|false"
    cpuMask="num"
    userName="<username>"
    password="<secure password>"
    logLevel="All|None|Errors"
    clientConnectedCheck="hrs:mins:secs|Infinite"
    comAuthenticationLevel="Default|None|Connect|Call| 
    Pkt|PktIntegrity|PktPrivacy"
    comImpersonationLevel="Default|Anonymous|Identify|
    Impersonate|Delegate"
    responseDeadlockInterval="hrs:mins:secs|Infinite"
    responseRestartDeadlockInterval="hrs:mins:secs|Infinite"
    autoConfig="true|false"
    maxWorkerThreads="num"
    maxIoThreads="num"
    minWorkerThreads="num"
    minIoThreads="num"
    serverErrorMessageFile="" 
    pingFrequency="Infinite" 
    pingTimeout="Infinite" 
    maxAppDomains="2000"
/>
With maxWorkerThreads and minWorkerThreads, you set up the minimum and maximum number of HttpApplications.
For more information, have a look at: ProcessModel Element.
Just to clarify what we have said until now, we can say that against a request to a WebApplication, we have:
  • A Worker Process w3wp.exe is started (if it is not running).
  • An instance of ApplicationManager is created.
  • An ApplicationPool is created.
  • An instance of a Hosting Environment is created.
  • A pool of HttpAplication instances is created (defined with the machine.config).
Until now, we talked about just one WebApplication, let's say WebSite1, under IIS. What happens if we create another application under IIS for WebSite2?
  • We will have the same process explained above.
  • WebSite2 will be executed within the existing Worker Process w3wp.exe (where WebSite1 is running).
  • The same Application Manager instance will manage WebSite2 as well. There is always an instance per Work Proces w3wp.exe.
  • WebSite2 will have its own AppDomain and Hosting Environment.
  • Within a new AppDomain will be run instances of WebSite2 (HttpApplication instances).


It's very important to notice that each web application runs in a separate AppDomain so that if one fails or does something wrong, it won't affect the other web apps that can carry on their work. At this point, we should have another question:
What would happen if a Web Application, let's say WebSite1, does something wrong affecting the Worker Process (even if it's quite difficult)?
What if I want to recycle the application domain?
To summarize what we have said, an AppPool consists of one or more processes. Each web application that you are running consists of (usually, IIRC) an Application Domain. The issue is when you assign multiple web applications to the same AppPool, while they are separated by the Application Domain boundary, they are still in the same process (w3wp.exe). This can be less reliable/secure than using a separate AppPool for each web application. On the other hand, it can improve performance by reducing the overhead of multiple processes.
An Internet Information Services (IIS) application pool is a grouping of URLs that is routed to one or more worker processes. Because application pools define a set of web applications that share one or more worker processes, they provide a convenient way to administer a set of web sites and applications and their corresponding worker processes. Process boundaries separate each worker process; therefore, a web site or application in an application pool will not be affected by application problems in other application pools. Application pools significantly increase both the reliability and manageability of a web infrastructure.


I want to better understand the difference between an AppDomain and an Application Pool

Just for better understanding, let's say you are working with Internet Explorer. As you know, you can open more than one tab for browsing more than one web site in the same instance of IE.
Let' say you open four tabs browsing different web sites, so that each tab will show a different web site.


After lots of pints of beer, let's assume that each tab is running within a different App Domain and each web site we are browsing is a different web app under IIS. All the web sites we are browsing are sharing the same instance of IE (iexplorer.exe). In this example, let's compare the IE instance (iexplorer.exe) to the ASP.NET Worker Process (w3wp.exe). If one tab is stuck for any reason (as sometime happens :-)), it's going to affect all the other tabs running under the same iexplorer.exe instance (some times, IE gets stuck and it doesn't respond to any interaction anymore, showing Not responding), so you are forced to kill the process to carry on working.
By killing the process, you will not able to browse any of the web sites you were browsing, even if it was just one process that made got IE stuck.


So what can we do if we want to isolate web site browsing at process level so that if one web site does something wrong, we can carry on browsing the other web sites? Simple, you can open two instance of IE and open two tabs on each instance. In this case, two iexplore.exe instances will be running, and they will be completely independent of each other: if a tab is stuck on one instance of Internet Explorer, you can kill that process, but the other one will carry on to work.


At this point, you should have an idea of what is happening in depth during a web request.
Of course, I should say lots more regarding this topic, but the scope of this article is just to give you an idea of what is really happening internally in IIS/ASP.NET and all the objects that are created to satisfy a web request.

References