//This link will help for read about HttpHandler and HttpModule
http://geekswithblogs.net/flanakin/articles/ModuleHandlerIntro.aspx
Introduction
All requests to IIS are handled through Internet Server Application Programming Interface (ISAPI) extensions. ASP.NET has its own filter to ensure pages are processed appropriately. By default, the ASP.NET ISAPI filter (aspnet_isapi.dll) only handles ASPX, ASMX, and all other non-display file formats used by .NET and Visual Studio. However, this filter can be registered with other extensions in order to handle requests to those file types, too, but that will be covered later.
Every request flows through a number of HTTP modules, which cover various areas of the application (i.e. authentication and session intofmation). After passing through each module, the request is assigned to a single HTTP handler, which determines how the system will respond to the request. Upon completion of the request handler, the response flows back through the HTTP modules to the user.
HTTP Module
HTTP modules are executed before and after the handler and provide a method for interacting with the request. Custom modules must implement the System.Web.IHttpModule interface. Modules are typically synchronized with events of the System.Web.IHttpModule class (implemented within the Global.asax.cs or .vb file). The following consists of a list of events that should be considered when implementing your module:
BeginRequest
AuthenticateRequest
AuthorizeRequest
ResolveRequestCache
AcquireRequestState
PreRequestHandlerExecute
PostRequestHandlerExecute
ReleaseRequestState
UpdateRequestCache
EndRequest
PreSendRequestHeaders*
PreSendRequestContent*
Error*
The events identified by an asterisk (*) can occur at any time within the request; all others are listed in their calling order.
HTTP Handlers
HTTP handlers proces the request and are generally responsible for initiating necessary business logic tied to the request. Custom handlers must implement the System.Web.IHttpHandler interface. Additionally, a handler factory can be created which will analyze a request to determine what HTTP handler is appropriate. Custom handler factories implement the System.Web.IHttpHandlerFactory interface.
Tuesday, January 18, 2011
Dataset- Filter Row Through DefaultView
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SchoolsConnectionString"].ConnectionString);
DataSet ds = new DataSet();
SqlDataAdapter adp = new SqlDataAdapter("select * from students", con);
Dataset ds = new DataSet();
adp.Fill(ds);
string message;
ds.Tables[0].DefaultView.RowFilter = "Name='Subhash'";
if (ds.Tables[0].DefaultView.Count != 0)
{
message = ds.Tables[0].DefaultView[0].Row["LastName"].ToString();
}
else
{
message = "";
}
DataSet ds = new DataSet();
SqlDataAdapter adp = new SqlDataAdapter("select * from students", con);
Dataset ds = new DataSet();
adp.Fill(ds);
string message;
ds.Tables[0].DefaultView.RowFilter = "Name='Subhash'";
if (ds.Tables[0].DefaultView.Count != 0)
{
message = ds.Tables[0].DefaultView[0].Row["LastName"].ToString();
}
else
{
message = "";
}
Log4Net(for Making logger file)
//This is the link where you can read about log4Net
//open source provide by Microsoft
http://www.codeproject.com/KB/dotnet/Log4net_Tutorial.aspx
http://www.beefycode.com/post/Log4Net-Tutorial-pt-1-Getting-Started.aspx
http://shiman.wordpress.com/2008/07/09/how-to-log-in-c-net-with-log4net-a-tutorial/Here is
great example for sending logfile into mail......
use the logger to log a few statements with various severity levels. log4net defines 5 such levels:
Log4Net supports five levels of logs with five methods.
Debug: fine-grained statements concerning program state, typically used for debugging;
Info: informational statements concerning program state, representing program events or behavior tracking;
Warn: statements that describe potentially harmful events or states in the program;
Error: statements that describe non-fatal errors in the application; this level is used quite often for logging handled exceptions;
Fatal: statements representing the most severe of error conditions, assumedly resulting in program termination.
we have to add Log4Net Dll in Add reference section.
after that Inside the AssemblyInfo.cs
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Web.config", Watch = true)]
and add some code in web.config file..
section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" requirePermission="false"/>
log4net debug="true">
appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
file value="Log4net\\log4net.txt"/>
appendToFile value="true"/>
rollingStyle value="Size"/>
maxSizeRollBackups value="10"/>
maximumFileSize value="50KB"/>
staticLogFileName value="true"/>
lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
layout type="log4net.Layout.PatternLayout">
conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n"/>
/layout>
/appender>
root>
level value="ALL"/>
appender-ref ref="RollingLogFileAppender"/>
/root>
/log4net>
add key="log4net.Internal.Debug" value="true" />
/appSettings>
//////////and Inside the .cs page
using log4net;//Add class in page
//Define Globally
private static readonly log4net.ILog log = log4net.LogManager.GetLogger("_Default");
//use like this
protected void Page_Load(object sender, EventArgs e)
{
try
{
int a = 0;
int b = 1;
int c = b / a;
}
catch (Exception ex)
{
log.Error(ex.Message, ex);//here is using
}
}
//open source provide by Microsoft
http://www.codeproject.com/KB/dotnet/Log4net_Tutorial.aspx
http://www.beefycode.com/post/Log4Net-Tutorial-pt-1-Getting-Started.aspx
http://shiman.wordpress.com/2008/07/09/how-to-log-in-c-net-with-log4net-a-tutorial/Here is
great example for sending logfile into mail......
use the logger to log a few statements with various severity levels. log4net defines 5 such levels:
Log4Net supports five levels of logs with five methods.
Debug: fine-grained statements concerning program state, typically used for debugging;
Info: informational statements concerning program state, representing program events or behavior tracking;
Warn: statements that describe potentially harmful events or states in the program;
Error: statements that describe non-fatal errors in the application; this level is used quite often for logging handled exceptions;
Fatal: statements representing the most severe of error conditions, assumedly resulting in program termination.
we have to add Log4Net Dll in Add reference section.
after that Inside the AssemblyInfo.cs
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Web.config", Watch = true)]
and add some code in web.config file..
section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" requirePermission="false"/>
log4net debug="true">
appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
file value="Log4net\\log4net.txt"/>
appendToFile value="true"/>
rollingStyle value="Size"/>
maxSizeRollBackups value="10"/>
maximumFileSize value="50KB"/>
staticLogFileName value="true"/>
lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
layout type="log4net.Layout.PatternLayout">
conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n"/>
/layout>
/appender>
root>
level value="ALL"/>
appender-ref ref="RollingLogFileAppender"/>
/root>
/log4net>
add key="log4net.Internal.Debug" value="true" />
/appSettings>
//////////and Inside the .cs page
using log4net;//Add class in page
//Define Globally
private static readonly log4net.ILog log = log4net.LogManager.GetLogger("_Default");
//use like this
protected void Page_Load(object sender, EventArgs e)
{
try
{
int a = 0;
int b = 1;
int c = b / a;
}
catch (Exception ex)
{
log.Error(ex.Message, ex);//here is using
}
}
Labels:
Log4Net(for Making logger file)
Subscribe to:
Posts (Atom)