Vijay Thombare

Vijay Thombare

  • NA
  • 8
  • 39.2k

Application_Error in global.asax

Jan 9 2010 3:15 AM

1] DALĀ 
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
using DataObjectLayer;

namespace DataAccessLayer
{
public class UserDAL
{
public int UserAuthenticated(UserObj User)
{
int retVal = 0;
OleDbConnection conn = new OleDbConnection(DBConn.GetDbConnection());
OleDbCommand comm = new OleDbCommand();
string sql = "Select * From [User_Master$] where UserId = '" + User.UserName + "' and Pasw = '" + User.Password + "'";
try
{
comm.Connection = conn;
conn.Open();
comm.CommandText = sql;
comm.CommandType = CommandType.Text;

retVal = Convert.ToInt32(comm.ExecuteScalar());
conn.Close();
}
catch (Exception ex)
{
throw;
}
return retVal;
}
}
}




2] Global.asax


<%@ Application Language="C#" %>

<script runat="server">

void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup

}

void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown

}

protected void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
Exception ex = HttpContext.Current.Server.GetLastError();
Response.Redirect("Error.aspx?Error=" + ex);
HttpContext.Current.Server.ClearError();
}

void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started

}

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.

}

</script>




my problem is when exception in occurs in DAL it cant show me Error.aspx which i mentioned in global.asax..please help me

Answers (3)