here is the error:
Server Error in '/CHAT' Application.
------------------------------------------------------------------------
--------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
av.a(String A_0) +32
bw.a(String A_0) +15
a3.a(Int32 A_0, String A_1) +78
chat_net3.ZbChatPage.UserLogout(Int32 iSiteId, String sUserName,
Int32& iErr, String& sErr) +78
ChatAPISample.CustomLogin.Button2_Click(Object sender, EventArgs e)
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.Rai
sePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1292
it happens when there is no cookie in the machine accessing the page
and this is the button2_click code:
private void Button2_Click(object sender, System.EventArgs e)
{
int iSiteId=int.Parse(this.SiteIdGet());
// This is just a sample. In real application you would take those
// variable form session, form, cookies or any other method that you
use.
//string sUserId="user1";
HttpCookie cookie = Request.Cookies["snitz00user"];
if(cookie == null)
{
//CookieValue represents a WebForm Label control
lblMsg.Text=string.Format("Failed to log in user");
}
else
{
//CookieValue represents a WebForm Label control
lblMsg.Text=string.Format("work");
}
try
{
sUserId = cookie.Values["Name"].ToString();
}
catch
{
lblMsg.Text=string.Format("Failed to log in user");
}
// string sUserId="user1";
string sErr="";int iErr=0;
if(this.UserLogout(iSiteId,sUserId,ref iErr,ref sErr))
{
lblLogout.Text=string.Format("Successfully logged out user {0} from
site {1}.",sUserId,iSiteId);
//instead you can just put all this code in your page_load event and
use redirect to chat page here.
//lnkChat.Visible=true;
}
else
{
//depending on error code you may take different action here
lblLogout.Text=string.Format("Failed to log out user {0} from site
{1}. Error ({2}) {3}",sUserId,iSiteId,iErr,sErr);
}
RoomListRender();
lnkChat.Visible=false;
------------------------------------------------------------------------
--------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
ASP.NET Version:1.1.4322.2300
*** Sent via Developersdex
http://www.developersdex.com ***