Friday, May 8, 2009

HTTP Modules Versus Global.asax Files

You can implement much of the functionality of a module in the application's Global.asax file, which enables you to respond to application events. However, modules have an advantage over the Global.asax file because they are encapsulated and can be created one time and used in many different applications. By adding them to the global assembly cache and registering them in the Machine.config file, you can reuse them across applications. For more information, see Global Assembly Cache.

The advantage of using the Global.asax file is that you can handle other registered events such as Session_Start and Session_End. In addition, the Global.asax file enables you to instantiate global objects that are available throughout the application.
You should use a module whenever you must create code that depends on application events, and when the following conditions are true:
# You want to re-use the module in other applications.
# You want to avoid putting complex code in the Global.asax file.
# The module applies to all requests in the pipeline (IIS 7.0 Integrated mode only).
You should add code in the Global.asax file whenever you must create code that depends on application events and you do not have to reuse it across applications. You can also use the Global.asax file when you have to subscribe to events that are not available to modules, such as Session_Start.

Global.asax file is derived from HttpApplication class and it does not implement IHttpModule interface like custom modules. If you are not going to use your custom module in any other application or don’t have complex logic than you should use Global.asax instead of creating custom modules.
You can have multiple modules in your web application implementing same events. Modules are called in the sequence they are added in the web.config file. With in a module events are called in following sequence:

BeginRequest
AuthenticateRequest
AuthorizeRequest
ResolveRequestCache
AcquireRequestState
PreRequestHandlerExecute
PostRequestHandlerExecute
ReleaseRequestState
UpdateRequestCache
EndRequest
PreSendRequestHeaders
PreSendRequestContent
Error

Event calling sequence in multi module Scenario:
Suppose there are Global.asax and 2 custom modules namely Module.cs and Module1.cs in an application. Custom modules are added in web.config in following order.

< httpModules >
< add name="MyModule1" type="MyModule1" />
< add name="MyModule" type="MyModule" />
< /httpModules >

And all of them are handling first 3 event in the above given list – BeginRequest , AuthenticateRequest, AuthorizeRequest.

The sequence of event call will be as follows:

Application_Start - Global.asax
Init - Global.asax
BeginRequest - MyModule1
BeginRequest - MyModule
BeginRequest - Global.asax
AuthenticateRequest - MyModule1
AuthenticateRequest - MyModule
AuthenticateRequest - Global.asax
AuthorizeRequest - MyModule1
AuthorizeRequest - MyModule
AuthorizeRequest - Global.asax
Session_Start - Global.asax
Page_Load

What is the difference between ETL tool and OLAP tool?

ETL:
Extract, Transform and Load. This is a product to extract the data from multiple/single source transform the data and load it into a table, flat file or simply a target.
There is a quite a bit competition in the market with regard to the ETL product as well as the OLAP products. These tools would definitely be widely used for data load and data analysis purpose.
ETL tools in market

1 INFORMATICA-- univeral tool good market
2 ABINITO -- fastest loading tool very good market
3 DATASTAGE-- difficult work no good market
4 BODI-- good market
5 ORACLE WAREHOUSE BUILDER-- good market

ETL Tools is for Extracting source data, Transforming as required and Loading into DW. it is first part of DW. Now large fact and dimension tables are in DW. If you have to generate crosstab report from these tables, it will take very long time. So these DW tables are transformed into Cubes and stored in OLAP Server. Any Report Generation, Analysis is done on these... Cubes are having pre aggregated values and hence Report Generation will be much faster.

OLAP:
Its an online analytical processing tool. There are various products available for data analysis. Like Hyperion which is a Business Intelligence (BI) and Business Performance Management (BPM ) Tool like Brio, Business Objects and Cognos etc. Its the market leader in Financial, Operational and Strategic Planning. It has applications for Planning, consolidation, scorecarding, reporting, dashboards, Analysis, Workspace, Master Data Management and Foundation.

The Difference between the two:
There are only 2 ways available to get data from a datawarehouse or a database.one is using sql statement and other method is using an OLAP tool(ex:cognos, business objects.....)So Hyperion is an example for a OLAP tool. ETL is a process of Extracting data from a source systems(a system where client's transactional business information resides) and performing business logic(applying TRANSFORMATION rules) on the collected source information(business logic depends on business requirements), and LOADING the precise data into a warehouse(probably a relational database). OLAP comes into picture after ETL developers design the warehouse........by using olap tools a business user can generate standard reports(without having sql knowledge he can do this)

How to configure application services in asp.net

Here I am not going to explain what is application service in asp.net, for that you can see my post -
Using Web Parts with SQL Server 2000/2005.

Configuring application services in your asp.net application is a two step process:

1. Configure database objects that will hold application services data.
2. Configure providers that will provide access to application services data from the database.

For Configure database objects use following sql script that will create database & its objects(tables, Sps) for storing application services objects.
These are found at :\WINDOWS\Microsoft.NET\Framework\v2.0.50727

InstallCommon.sql
InstallMembership.sql
InstallPersonalization.sql
InstallProfile.sql
InstallRoles.sql

Make sure you run "InstallCommon.sql" script first as it creates database before running other scripts. By default database name is "aspnetdb" but if you want to change it, you can update InstallCommon.sql script.
These sql scripts are handy if you dont want to use all application services or you dont want to create separate database for it. In that case you can run any one or all script(s) depending upon the service you want to use on your application database. like if you want to implement only personalization then you just need to run "InstallPersonalization.sql" on your main database.

You can unstall these objects as well using following sql scripts.

UninstallCommon.sql
UninstallMembership.sql
UninstallPersonalization.sql
UninstallProfile.sql
UninstallRoles.sql

For example you may want to use only personization service not profile, membership and role service in that case there is no point to have other services configured in the application.
So you can run InstallCommon.sql followed by InstallProfile.sql sql scripts.
Note:- dont forget to change database name in the InstallCommon.sql sql script with the database in which you want to configure application service data objects.

You can do same thing using aspnet_regsql.exe utility as well using following command at the command prompt.

aspnet_regsql.exe -S < server name > -U < username > -P < password > -A < service code > -d < database name >

service code - all : all services
m : membership
r : role manager
p : profile
c : personalization
w : sql web event provider

For example if you have to add only profile service in your existing database, run following command at the command prompt:

aspnet_regsql.exe -S myserver -U user1 -P pass1 -A p -d mydb

Note:- replace server name, user name, password and database name with user's.

To remove profile service use -R in place of -A

Like:- aspnet_regsql.exe -S myserver -U user1 -P pass1 -R p -d mydb

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

Second step is to configure providers in the web application.
Below is the code sample that can be added in the web.config file depending upon the application service you want to configure in your web application.

Provider's configuration in web.config file.

< !-- Connection string will point to the database that is configured to store application service data -- >
< connectionStrings >
< add name="SQLConnString" connectionString="Data Source=FN-WS282-D8;Initial Catalog=AppServices;Integrated Security=false; user id=sa; pwd=pass1" providerName="System.Data.SqlClient" />
< /connectionStrings >

< !-- Add following code for configuring personalization in the web.config file -- >
< webParts >
< personalization defaultProvider="SqlPersonalizationProvider" >
< providers >
< add name="SqlPersonalizationProvider" type="System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider" connectionStringName="SQLConnString" applicationName="/" />
< /providers >
< authorization >
< deny users="*" verbs="enterSharedScope" />
< allow users="*" verbs="modifyState" />
< /authorization >
< /personalization >
< /webParts >

< !-- Add following code for configuring profile in the web.config file -- >
< profile defaultProvider="SqlProfileProvider" >
< providers >
< clear />
< add name="SqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="SQLConnString" applicationName="/" />
< /providers >
< properties >
< add name="Message" type="System.String" />
< /properties >
< /profile >

< !-- Add following code for configuring membership in the web.config file -- >
< membership defaultProvider="SqlMembershipProvider" >
< providers >
< clear />
< add name="SqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="SQLConnString" applicationName="/" />
< /providers >
< /membership >

< !-- Add following code for configuring role manager in the web.config file -- >
< roleManager defaultProvider="SqlRoleProvider" >
< providers >
< clear />
< add name="SqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="SQLConnString" applicationName="/" />
< /providers >
< /roleManager >