calling application_end

  • Thread starter Thread starter newbie
  • Start date Start date
N

newbie

My application_end event in global.asax is not working as-is. In order
to debug, I want to call it from another file, say debug.aspx through a
button, e.g. "end application". How do I call application_end in
global.asax from debug.aspx?

thanks
 
Hi,
I have a problem, in my project. . .
How can i close the all the Sessions (Session.Abandon) and Explorer Window
with out any Confirmation.
 
In my project i am trying to maintain the Windows Authentication (Basic
Authentication), the problem is like when i get to some pages the user will
be displayed with the Windows authentication page and some images will not
be displayed

i though like "_currUserIdentity = User.Identity.Name.ToString();" by this
the problem is occuring as it is trying to find the User Identity every
time. . .
please try to solve the problem, user should not get the window untill the
session time out. . .

here is the following code used in the global.asax

---------------------------------------------------------------------------------------
protected void Session_Start(Object sender, EventArgs e)
{
_currUserIdentity = User.Identity.Name.ToString();
Session["currUserIdentity"] = _currUserIdentity;

try
{
Users usr=new Users();
usr.GetUserByLoginName(_currUserIdentity);
DataSet dsUser=usr.GetDataSet();
if (dsUser.Tables[0].Rows.Count==0)
{
Session["CurrentUserName"] = _currUserName;
Response.Redirect("UnAuthorisedAccess.aspx");
}
else if(dsUser.Tables[0].Rows.Count == 1)
{
Session["CurrentClientID"] =
dsUser.Tables[0].Rows[0]["ClientID"].ToString();
Session["UserID"] =
Convert.ToInt32(dsUser.Tables[0].Rows[0]["UserID"].ToString());
Response.Redirect("index.aspx");
}
else
{
Session["UserName"] = dsUser.Tables[0].Rows[0]["LoginName"].ToString();
Response.Redirect("SelectClient.aspx");
}
}
catch(Exception ex)
{
Session["ErrorMessage"] = ex.ToString();
}
}
 
How can i close the all the Sessions (Session.Abandon)

When you say "all the Sessions", do you mean you want to (effectively) throw
all users off your web application...?
and Explorer Window with out any Confirmation.

Hmm - again, what exactly are you trying to achieve here...?
 
newbie said:
My application_end event in global.asax is not working as-is. In order
to debug, I want to call it from another file, say debug.aspx through
a button, e.g. "end application". How do I call application_end in
global.asax from debug.aspx?

thanks

You can write in debug.aspx:
XmlDocument doc=new XmlDocument();
doc.Load(Request.MapPath("web.config"));
doc.Save(Request.MapPath("web.config"));
 
This is like i want to close the particular window rather than all the users
using the application. . .
just i want to close the page.
 
This is like i want to close the particular window rather than all the
users using the application. . .
just i want to close the page.

I see - it was your phrase "all the Sessions" which made me wonder...

If you just want to tear down a session, put Session.Abandon() in the
Page_Load of the page where you want this to happen and Response.Redirect to
another page.
 
JavaScript: window.close();

The behavior of the browser will differ according to how the window was
opened in the first place. If the user opened the browser window, the user
will be prompted and asked if he/she wants the window closed. If the window
was opoened by another browser window, it will close immediately.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Paranoia is just a state of mind.
 
According to you, i tried it, but the problem is like the user willl be
displayed with the Confirmation message, if the user selects no

private void lnkClose_Click(object sender, System.EventArgs e)
{
Response.Write("<script language=javascript>window.close(); </script>");
Response.Cookies.Clear();
FormsAuthentication.SignOut();
Session.Abandon();
Session.Clear();
ViewState.Clear();
}
please guide me. .. i should not have any confirmation and then close the
window.
 
I solved the problem, i had put all the sessions and all the code in the
page load and by that user will be asked for yes or no if he tries to use
the back button(IE) the user is again taken to the first page with new
sessions

Thankyou. . ..
 
please guide me. .. i should not have any confirmation and then close the
window.
Response.Write("<script language=javascript>window.close(); </script>");

Response.Write("<script
language=javascript>window.opener=null;window.close(); </script>");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top