Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

How can I close my web page application in asp C# when a button is clicked?

Hi, I want to close and exit my web page when a button is close.  How can I do this?  Thanks.
        protected void btnExit_Click(object sender, EventArgs e)
  • 3
1 Solution
What do you mean by "exit"? Do you mean to close the window? Or the browser completely? Or do you want to restart the web site on IIS? Or just show the entry page of your web site?
Suppose you want to exit the whole browser: in most cases, cannot be done due to modern protection of the browser due to the tab pages etc.

Suppose you want to exit only the current page, but leave the browser, by means of closing the window of the page: this can only be done when your application has opened the window. In that case, you can call:

<input type="button" onclick="window.close();" value="close window" />

which is client-side javascript, you cannot do this from the server.

Suppose you want to exit the whole asp.net application on the server... well,... if you really want to do that I wouldn't mind diving into that, but your primary concern will be leveraging security.

-- Abel --
lapuccaAuthor Commented:
Right, what you say makes a lot of sense.  I have been a windows developer and new to web development.  Of course, users would close the browser themself or change url to anther web page or we site.  I guess there is never any need for me to worry about closing anying page like I would in windows application.  Thank you.
you're welcome. And indeed, a web application always continues to run. Though matters of "starting" and "stopping" are done by means of logging in and out of the web application.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now