28 June, 2009

Asp.Net Question Bank

What is the Website Administrative Tool in ASP.NET 2.0 ?

In ASP.NET 2.0, while using Visual Studio 2005 Express Edition or above, the development IDE provides an interface for editing the web.config rather than manually editing the web.config.

In the IDE, click on "Website" and then on "ASP.NET Configuration". This shall open the Website configuration tool. Note that the Web Site Administration Tool is a set of prebuilt ASP.NET 2.0 webpages and resources that are located within the C:\Inetpub\wwwroot\aspnet_webadmin\2_0_40607 directory.

Describe the security authentication flow and process in ASP.NET?

When a user requests a web page, there exists a process of security too, so that every anonymous user is checked for authentication before gaining access to the webpage. The following points are followed in the sequence for authentication when a client attempts a page request:

* A .aspx web page residing on an IIS web server is requested by an end user
* IIS checks for the user's credentials
* Authentication is done by IIS. If authenticated, a token is passed to the ASP.NET worker process along with the request
* Based on the authentication token from IIS, and on the web.config settings for the requested resource, ASP.NET impersonates the end user to the request thread. For impersonation, the web.config impersonate attribute's value is checked.

What are the types of WPF Applications ?

The following four types of WPF applications are available through .NET Framework 3.0 within Visual Studio 2005:

❑ .NET Framework 3.0 Windows Application—The .NET Framework 3.0 Windows Application is essentially the equivalent of a .NET Windows Forms project with all the perks of the WPF API.

❑ .NET Framework 3.0 XAML Browser Application—The .NET Framework 3.0 XAML Browser Application (XBAP) is the WPF version of an ASP.NET web application, with a limited amount of WPF namespaces and functionality available to it, because of the browser’s security access limitations on the client.

❑ .NET Framework 3.0 Service Library Project—The .NET Framework 3.0 Service Library is a Windows Communication Foundation project type and is not held within its sibling WPF platform.

❑ .NET Framework 3.0 Custom Control Library Project—The .NET Framework 3.0 Custom
Control Library is a project designed to output a reusable control that can be redistributed to a .NET application in the form of a dynamic-link library (DLL) .NET assembly.

What is one way operation?

IsOneWay equal to true ensures that the client does not have to wait for the response. So methods marked by IsOneWay to true should always return void. In this the caller does not get anything in return so it is called as one-way communication. In order to understand one way implementation in WCF lets make a code walkthrough of a sample.

Above is the code snippet which describes practically how one way works in WCF. The above given code snippet is numbered. Below is the explanation according to the numbers marked in figure:
1 - This is the code snippet of the server service. We have created a method called as doHugeTask. doHugeTask basically makes the method sleep for 5000 MS and then displays the time when the task is completed.
2 - This code snippet is for client. It creates a proxy object of serviceIsOneWay and calls the doHugeTask method. After calling the doHugeTask the client execution continues ahead. So as a proof we display the time when the method calling was completed.
3 - This screen shot shows the output given by both server and client. The top window displays the server output and the below windows displays the client output.
So run the server program first i.e. ServiceIsOneWay and run the client later. You will see the client runs the doHugeTask and moves ahead. So the client completion time is less than the server. One more thing to understand is that one way does not give any notification back of completion. So it’s like fire and forget.

Before in my VB app I would just load the icons from DLL. How can I load the icons provided by .NET dynamically?

By using System.Drawing.SystemIcons class' for example System.Drawing.SystemIcons.Warning produces an Icon with a warning sign in it.

What,s typical about a Windows process in regards to memory allocation?

Each process is allocated its own block of available RAM space' no process can access another process' code or data. If the process crashes' it dies alone without taking the entire OS or a bunch of other applications down.

What are the various ways of hosting a WCF service?

There are three major ways to host a WCF service:

Self hosting the service in his own application domain. This we have already covered in the first section. The service comes in to existence when you create the object of ServiceHost class and the service closes when you call the Close of the ServiceHost class.
Host in application domain or process provided by IIS Server.
Host in Application domain and process provided by WAS (Windows Activation Service) Server.

what are the advantages of hosting WCF Services in IIS as compared to self hosting?

There are two main advantages of using IIS over self hosting:
Automatic activation
IIS provides automatic activation that means the service is not necessary to be running in advance. When any message is received by the service it then launches and fulfills the request. But in case of self hosting the service should always be running.
Process recycling
If IIS finds that a service is not healthy that means if it has memory leaks etc, IIS recycles the process. Ok let us try to understand what is recycling in IIS process. For every browser instance a worker process is spawned and the request is serviced. When the browser disconnects the worker process stops and you loose all information. IIS also restarts the worker process. By default the worker process is recycled at around 120 minutes. So why does IIS recycle. By restarting the worker process it ensures any bad code or memory leak do not cause issue to the whole system.
In case of self hosting both the above features you will need to code yourself. Lot of work right!!. That's why IIS is the best option for hosting services until you are really doing something custom.
Below figure shows where the recycle option is located in IIS. You need to click on the DefaultAppool and then Properties.

No comments: