HighTechTalks DotNet Forums  

Session State between application layers

Dotnet Distributed Applications microsoft.public.dotnet.distributed_apps


Discuss Session State between application layers in the Dotnet Distributed Applications forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Moojjoo
 
Posts: n/a

Default Session State between application layers - 06-24-2010 , 08:57 AM






From my UI > Service > BL I am creating a service that will pass exceptions
to a backend database log.

However I am returing the SCOPE_IDENTITY from the DB.

I then am attempting to create in the BL

HttpContext ctx = HttpContext.Current;

Then after the call to the DB I am attempting to set a session variable:

ctx.Session["myErrorID"] = EID.ToString();

However I am getting ctx.Session does not exsit...

Any help would be great.





--
Moojjoo
http://moojjoo.blogspot.com

Reply With Quote
  #2  
Old   
Moojjoo
 
Posts: n/a

Default RE: Session State between application layers - 06-25-2010 , 12:15 PM






More information:

Object reference not set to an instance of an object.

-------------------
Here is the code:
public void HandleException(LogException logObject)
{
HttpContext ctx = HttpContext.Current;


bool logIt = Properties.Settings.Default.LogErrors;
int EID = -1;

if (logIt)
{
String sPageName = "";
if (ctx.Request.ServerVariables["PATH_INFO"] != null)
{
string[] str =
ctx.Request.ServerVariables["PATH_INFO"].ToString().Split('/');
sPageName = str[str.Length - 1];
}


try
{
DbCommand dbCommand =
db.GetStoredProcCommand("spInsertApplicationErrorL og");
db.AddInParameter(dbCommand, "@NBID", DbType.String,
logObject.CurrentNBID);
db.AddInParameter(dbCommand, "@ErrorMsg", DbType.String,
logObject.ErrorMsg);
db.AddInParameter(dbCommand, "@ErrorPage",
DbType.String, sPageName.ToString());
db.AddInParameter(dbCommand, "@ErrorStacktrace",
DbType.String, logObject.ErrorStack);
db.AddOutParameter(dbCommand, "@EID", DbType.Int32, 100);
EID = db.ExecuteNonQuery(dbCommand);
EID = (int)db.GetParameterValue(dbCommand, "@EID");
ctx.Session["myErrorID"] = "-1";//EID.ToString();

//if you are doing debug locally, you can comment out
sendEmail below
#if DEBUG
sendEmail(EID, logObject);
#else
sendEmail(EID, ex);
#endif

//local testing sendEmail(164, ex);
}
catch (Exception exc)
{
EventLog.WriteEntry(exc.Source, "The error cannot be
logged into DB, and it is throwed from Exception Log!",
EventLogEntryType.Error);
}
}
}
------------------------------------------------


--
Moojjoo
http://moojjoo.blogspot.com


"Moojjoo" wrote:

Quote:
From my UI > Service > BL I am creating a service that will pass exceptions
to a backend database log.

However I am returing the SCOPE_IDENTITY from the DB.

I then am attempting to create in the BL

HttpContext ctx = HttpContext.Current;

Then after the call to the DB I am attempting to set a session variable:

ctx.Session["myErrorID"] = EID.ToString();

However I am getting ctx.Session does not exsit...

Any help would be great.





--
Moojjoo
http://moojjoo.blogspot.com

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.