SQL Trigger using ASP.Net CLR - asp.net

So I'm trying to write a SQL Server Trigger that will call an ASP.Net DLL.
I have got everything talking, but I'm completely stumped that when the triggers fires it can not see the "inserted" table?!?!
Msg 6522, Level 16, State 1, Procedure etrition_train_trigger_clr35, Line 1
A .NET Framework error occurred during execution of user-defined routine or aggregate "etrition_train_trigger_clr35":
System.Data.SqlClient.SqlException: Invalid object name 'inserted'.
System.Data.SqlClient.SqlException:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader()
at CLRTrigger.CLRTrigger.SQLTriggerCall()
Here is my .Net Code. Like I said it fires off when the trigger condition is met, however it can't see the inserted table for some reason.
public static void SQLTriggerCall()
{
SqlTriggerContext triggContext = SqlContext.TriggerContext;
SqlConnection cn = new SqlConnection("Server=vm260101;Database=RT_Training;uid=XXXXXX;pwd=XXXXXXX;Enlist=False;");
cn.Open();
SqlCommand sqlComm = cn.CreateCommand();
SqlPipe sqlP = SqlContext.Pipe;
SqlDataReader dr;
sqlComm.CommandText = "SELECT stu_fee_gu, stu_fee_pay_trans_gu, amount from inserted";
dr = sqlComm.ExecuteReader();
String stu_fee_gu = "";
String stu_fee_pay_trans_gu = "";
float amount = 0;
while (dr.Read())
{
stu_fee_gu = Convert.ToString(dr["stu_fee_gu"]);
stu_fee_pay_trans_gu = Convert.ToString(dr["stu_fee_pay_trans_gu"]);
amount = (float)Convert.ToDecimal(dr["amount"]);
}
cn.Close();
}

The connection cn that you've opened doesn't share the same context as the trigger. Try using the context connection
See the examples under SqlTriggerContext for usage within a trigger, e.g.:
// Retrieve the connection that the trigger is using.
using (SqlConnection connection
= new SqlConnection(#"context connection=true"))
{
connection.Open();
// Get the inserted row.
command = new SqlCommand(#"SELECT * FROM INSERTED;",
connection);
// Get the user name and real name of the inserted user.
reader = command.ExecuteReader();
reader.Read();
//More...
Of course, the rest of that example is very poor, since it assumes only a single row in inserted. Don't make that mistake in your own code.

Related

ORMLite Dialects

I have followed the answer given to this [question] (http://stackoverflow.com/questions/13691575/servicestack-ormlite-with-mutliple-database-servers), but am still getting a error. The error is:
{System.Data.SqlClient.SqlException (0x80131904): Invalid object name 'dual'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at ServiceStack.MiniProfiler.Data.ProfiledDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at ServiceStack.OrmLite.OrmLiteReadExtensions.ExecReader(IDbCommand dbCmd, String sql) in C:\src\ServiceStack.OrmLite\src\ServiceStack.OrmLite\OrmLiteReadExtensions.cs:line 48
at ServiceStack.OrmLite.OrmLiteReadExtensions.GetScalar[T](IDbCommand dbCmd, String sql, Object[] sqlParams) in C:\src\ServiceStack.OrmLite\src\ServiceStack.OrmLite\OrmLiteReadExtensions.cs:line 498
at ServiceStack.OrmLite.Oracle.OracleOrmLiteDialectProvider.GetNextValue(IDbCommand dbCmd, String sequence, Object value)
at ServiceStack.OrmLite.Oracle.OracleOrmLiteDialectProvider.ToInsertRowStatement(Object objWithProperties, IList1 insertFields, IDbCommand dbCommand)
at ServiceStack.OrmLite.OrmLiteDialectProviderBase1.ToInsertRowStatement(Object objWithProperties, IDbCommand command) in C:\src\ServiceStack.OrmLite\src\ServiceStack.OrmLite\OrmLiteDialectProviderBase.cs:line 439
at ServiceStack.OrmLite.OrmLiteWriteExtensions.Insert[T](IDbCommand dbCmd, T[] objs) in C:\src\ServiceStack.OrmLite\src\ServiceStack.OrmLite\OrmLiteWriteExtensions.cs:line 394
at ServiceStack.OrmLite.OrmLiteWriteConnectionExtensions.<>c__DisplayClass421.b__41(IDbCommand dbCmd) in C:\src\ServiceStack.OrmLite\src\ServiceStack.OrmLite\OrmLiteWriteConnectionExtensions.cs:line 164
at ServiceStack.OrmLite.ReadConnectionExtensions.Exec(IDbConnection dbConn, Action1 filter) in C:\src\ServiceStack.OrmLite\src\ServiceStack.OrmLite\Expressions\ReadConnectionExtensions.cs:line 55
at ServiceStack.OrmLite.OrmLiteWriteConnectionExtensions.Insert[T](IDbConnection dbConn, T[] objs) in C:\src\ServiceStack.OrmLite\src\ServiceStack.OrmLite\OrmLiteWriteConnectionExtensions.cs:line 164
at ServiceStack.ServiceInterface.Auth.OrmLiteAuthRepository.<>c__DisplayClass5.<CreateUserAuth>b__4(IDbConnection db)
at ServiceStack.OrmLite.OrmLiteConnectionFactoryExtensions.Run[T](IDbConnectionFactory connectionFactory, Func2 runDbCommandsFn) in C:\src\ServiceStack.OrmLite\src\ServiceStack.OrmLite\OrmLiteConnectionFactory.cs:line 171
at ServiceStack.ServiceInterface.Auth.OrmLiteAuthRepository.CreateUserAuth(UserAuth newUser, String password)
at ServiceStack.ServiceInterface.Auth.RegistrationService.OnPost(Registration request)
at ServiceStack.ServiceInterface.RestServiceBase`1.Post(TRequest request)
ClientConnectionId:55977ae9-775d-474f-a543-d4cdfeb66a0d}
I am setting things up with the following code:
private void ConfigureAuth(Funq.Container container)
{
...
//Create a DB Factory configured to access the UserAuth SQL Server DB
var connStr = appSettings.Get("SQLSERVER_CONNECTION_STRING", //AppHarbor or Local connection string
ConfigUtils.GetConnectionString("UserAuth"));
container.Register<IDbConnectionFactory>(
new AuthDBConnectionFactory(connStr, //ConnectionString in Web.Config
SqlServerOrmLiteDialectProvider.Instance)
{
ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
});
//Store User Data into the referenced SqlServer database
container.Register<IUserAuthRepository>(c =>
new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>())); //Use OrmLite DB Connection to persist the UserAuth and AuthProvider info
var authRepo = (OrmLiteAuthRepository)container.Resolve<IUserAuthRepository>();
...
}
A little later I set up a connection to a vacancy database held on an oracle server:
private void ConfigureVacancies(Funq.Container container)
{
...
var connStr = appSettings.Get ("VACANCIES_CONNECTION_STRING", //AppHarbor or Local connection string
ConfigUtils.GetConnectionString("VacanciesDB"));
var dbFactory = (OrmLiteConnectionFactory)container.Resolve<IDbConnectionFactory>();
dbFactory.RegisterConnection("vacancies", connStr, ServiceStack.OrmLite.Oracle.OracleDialect.Provider);
...
}
The connection to the vacancies database works fine, but when I try to register a user on the auth database I get the error above. It seems to me that it is holding onto the Oracle Dialect?
I've dicovered that the autodispose connection is being used in the connection factory to also set the setGlobalConnection varible:
public void RegisterConnection(string connectionKey, string connectionString, IOrmLiteDialectProvider dialectProvider, bool autoDisposeConnection = true)
{
NamedConnections[connectionKey] = new OrmLiteConnectionFactory(connectionString, autoDisposeConnection, dialectProvider, autoDisposeConnection);
}
Is that intentional? I've modified my code to set autoDisposeConnection to False, this fixes my dialect problem and allows service stack to query Oracle and MS SQL. I've not quite worked out what the consequence of setting autoDisposeConnection to false is. All my tests are passing now though!

Windows Service SQL timeout exception

I have a Windows service which continuously each 10 seconds queries the SQL Server database table, and I also have a web site which also queries the same database table after 25 seconds.
After some time I get exception - server timeout exception has occurred. I went through stack-overflow site and has done the changes to SQL configuration settings but still I got the same exception. What to do?
Stack Trace
at System.Data.SqlClient.SqlConnection.OnError(SqlException
exception, Boolean breakConnection) at
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData() at
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,
RunBehavior runBehavior, String resetOptionsString) at
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async) at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result) at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method) at
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method) at
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior) at
System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at
Microsoft.Practices.EnterpriseLibrary.Data.Database.DoExecuteReader(DbCommand
command, CommandBehavior cmdBehavior) at
Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteReader(DbCommand
command) at
Microsoft.Practices.EnterpriseLibrary.Data.CommandAccessor1.<Execute>d__0.MoveNext()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
at System.Runtime.Remoting.Messaging.Message.Dispatch(Object target, Boolean fExecuteInContext) at
System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage
msg, Int32 methodPtr, Boolean fExecuteInContext)
Show me the code! timeout exception usually are because you don't close the database connection.
try add the code in the final of algorithm
if (connection.State == System.Data.ConnectionState.Open)
{
connection.Close();
connection.Dispose();
}
If you use to EnterpriseLibrary, try add more time to commandTimeOut
DbCommand dbcommand = database.GetStoredProcCommand("usp_TheStoredProcedureName");
dbcommand.CommandTimeout = 120;

Error on IIS for ASP.Net Application

I am facing this error occasionally. When I restart the IIS this problem is resolved. The web server(IIS) has more than 10 sites hosted, so i can't restart it simultaneously.
System.Data.SqlClient.SqlException: Distributed transaction completed. Either enlist
this session in a new transaction or the NULL transaction. at
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean
breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler,
SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at
System.Data.SqlClient.SqlDataReader.get_MetaData() at
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior
runBehavior, String resetOptionsString) at
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,
RunBehavior runBehavior, Boolean returnStream, Boolean async) at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior
runBehavior, Boolean returnStream, String method, DbAsyncResult result) at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior
runBehavior, Boolean returnStream, String method) at
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at
System.Data.SqlClient.SqlCommand.ExecuteReader() at MyLibrary.LoadDDList(DropDownList&
curDDL, String strTextField, String strValueField, String strTable, String svarconditional)
Please help me find a solution which preferably doesn't involve restarting IIS.
You have a function called LoadDDList in the MyLibrary class.
This function needs a Try Catch around the ExecuteReader() command.
Try
mySqlCommand.ExecuteReader()
Catch sqlException As SqlClient.SqlException
If sqlException.ErrorCode >= 10 Then
Throw
End If
End Try
In the catch, you want to check for an ErrorCode less than 10. If it's less than 10, then it's just a warning message and you can ignore it. If it's 10 or greater, you need to rethrow it, since it's an actual SQL error (parsing error, invalid table, etc.).
Looking at your stack, this is just a warning and should be ignored. You need to fix your code so you won't crash IIS when you hit this SQL Warning.

Suspect malicious probing in my asp.net ecommerce app

I am receiving repeated errors from my asp.net ecommerce web app. I am beginning to suspect an automated malicious probe as this is the twelfth attempt to access ProductId=69 which does not exist (ProductId 69 was removed month ago ). I have not found any info via google and hope someone recognizes this. Here is the log entry.
Page location:
/Product.aspx?ProductId=69
Message: Violation of PRIMARY KEY
constraint 'PK_ShoppingCart'. Cannot
insert duplicate key in object
'dbo.ShoppingCart'. The statement has
been terminated.
Source: .Net SqlClient Data Provider
Method: Void
OnError(System.Data.SqlClient.SqlException,
Boolean)
Stack Trace:
at
System.Data.SqlClient.SqlConnection.OnError(SqlException
exception, Boolean breakConnection) at
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj) at
System.Data.SqlClient.TdsParser.Run(RunBehavior
runBehavior, SqlCommand cmdHandler,
SqlDataReader dataStream,
BulkCopySimpleResultSet
bulkCopyHandler, TdsParserStateObject
stateObj) at
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader
ds, RunBehavior runBehavior, String
resetOptionsString) at
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior,
Boolean returnStream, Boolean async)
at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior,
Boolean returnStream, String method,
DbAsyncResult result) at
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult
result, String methodName, Boolean
sendToPipe) at
System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at
GenericDataAccess.ExecuteNonQuery(DbCommand
command)
After much observation I conclude that these page requests are bots, probably search engines.
Finally identified this error as a duplicate order attempt.

Error on Execution of a SP ASP.NET C#

public DataTable RunProc(String sProcName, SqlParameter[] arrParams)
{
string sClassName = "DBAccess.RunProc";
SqlConnection objSqlConnection = null;
try
{
objSqlConnection = (SqlConnection)OpenConnection();
string sLogMessage="Executing Stored Procedure: ["+ sProcName +"] with Parameters ";
foreach(SqlParameter objParameter in arrParams)
{
sLogMessage+=objParameter.ParameterName+" = ";
sLogMessage+=objParameter.Value+" ";
}
logger.Logns(LogLevel.TraceDetail,sClassName," ",sLogMessage);
SqlCommand objSqlCommand = CreateCommand(sProcName, arrParams,objSqlConnection,null);
objSqlCommand.CommandTimeout=300;
SqlDataAdapter objSQLDataAdapter = new SqlDataAdapter(objSqlCommand);
DataSet objDataSet = new DataSet();
objSQLDataAdapter.Fill(objDataSet);
this.CloseConnection(objSqlConnection);
logger.Logns(LogLevel.TraceDetail,sClassName," ","Success Executing Stored Procedure: ["+ sProcName +"]");
this.CloseConnection(objSqlConnection);
if( objDataSet.Tables.Count>0)
{
return objDataSet.Tables[0];
}
else
{
return null;
}
//SqlParameter p= new SqlParameter("PACCOUNTNUM", IBM.Data.DB2.DB2Type.VarChar, 17, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null);
}
catch(Exception Ex)
{
logger.Logns(LogLevel.TraceDetail,sClassName," ","Error Executing Stored Procedure: ["+ Ex.ToString() +"]");
this.CloseConnection(objSqlConnection);
throw(new Exception(Ex.ToString()));
}
}
The above mentioned code executes successfully in our production enviroment however all of the sudden we start getting Error in our logs
11/04/2011 09:42:46 AM|TraceDetail
|DBAccess.RunProc
| |Error
Executing Stored Procedure:
[System.Threading.ThreadAbortException:
Thread was being aborted. at
SNINativeMethodWrapper.SNIPacketGetConnection(IntPtr
packet) at
System.Data.SqlClient.TdsParserStateObject.ProcessSniPacket(IntPtr
packet, UInt32 error) at
System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult
asyncResult, TdsParserStateObject
stateObj) at
System.Data.SqlClient.TdsParserStateObject.ReadPacket(Int32
bytesExpected) at
System.Data.SqlClient.TdsParserStateObject.ReadBuffer()
at
System.Data.SqlClient.TdsParserStateObject.ReadByte()
at
System.Data.SqlClient.TdsParser.Run(RunBehavior
runBehavior, SqlCommand cmdHandler,
SqlDataReader dataStream,
BulkCopySimpleResultSet
bulkCopyHandler, TdsParserStateObject
stateObj) at
System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at
System.Data.SqlClient.SqlDataReader.get_MetaData()
at
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader
ds, RunBehavior runBehavior, String
resetOptionsString) at
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior,
Boolean returnStream, Boolean async)
at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior,
Boolean returnStream, String method,
DbAsyncResult result) at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior,
Boolean returnStream, String method)
at
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method) at
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior) at
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
behavior) at
System.Data.Common.DbDataAdapter.FillInternal(DataSet
dataset, DataTable[] datatables, Int32
startRecord, Int32 maxRecords, String
srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet
dataSet, Int32 startRecord, Int32
maxRecords, String srcTable,
IDbCommand command, CommandBehavior
behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet
dataSet) at
GDCIEngine.Data.PrismDb.DBAccess.RunProc(String
sProcName, SqlParameter[]
arrParams)]
The above mentioned code is used in a Web service which is called by presentation layer on the presentation layer i happen to recive HTTP Timedout however on the backend where the service is actually hosted the above mentioned exception is getting printed as soon as i do an iisreset on backend machine every thing start working as expected this error is showing up every now and then and iisreset being the only solution i have come up to cope up with it any help in this regard would be highly appreciated
Thanks
Regards
Azeem
You're getting the System.Threading.ThreadAbortException exception. It's a classic exception caused by Response.End, Response.Redirect, or Server.Transfer.
Something in your code is code is causing you to attempt to redirect. Possibly a lost database connection?
Unfortunately, the only way to fix this is to debug it or to try to fix it yourself.
Short of debugging (since it's production), you could try throwing log statements in at specific intervals throughout the function to try to narrow down where the problem is. e.g.
logger.Logns(LogLevel.TraceDetail,sClassName," ","Trace point 1")
... do some stuff ...
logger.Logns(LogLevel.TraceDetail,sClassName," ","Trace point 2")
... do some more stuff ...
logger.Logns(LogLevel.TraceDetail,sClassName," ","Trace point 1")
etc. That might be the only way to track this down.

Resources