ASP. NET background to enable and disable the website

Source: Internet
Author: User

1. Consider using froms verification for your purpose. Use Unlogged users to jump to your Upgrade instruction file.
You can add the following configuration file to Web. config.

<Authentication mode = "forms">
<Forms loginurl = "upgrade description file. aspx" name = ". xxxxxx">
</Forms>
</Authentication>
<Authorization>
<Deny users = "? "/>
</Authorization>

2. Add onrequest event processing in global. asax to directly redirect to an html
Then all aspx will be disabled, so you can put a Boolean in the application to determine whether redirect

3. The best method

Place a file in the root directory of the Website: app_offline. htm, which indicates that the file is being upgraded. The upgrade is complete and changed to another name. Note: The HTML characters in the file cannot be too small.

Use of app_offline.htm in Asp.net 2.0

1) modify the static html page file in Asp.net plain (case-insensitive) to the content you want to temporarily display and put it in the root directory of your application. In this way, any external requests will be immediately transferred to this page. At this time, your website can still be accessed, but your application cannot be accessed.
You can also use the ASP. NET configuration management tool under the website menu of vs.net 2005 to make your site offline.

2) When a user accesses a web site, the iiswill first check that the file app_offline.htm is in the directory, which seems to have a higher priority. Under the root directory of the ASP. NET 2.0 site, all requests to .aspxwill be directed to app_offline.htm if the app_offline.htm file exists. In addition, the address bar of the browser displays the requested. aspx URL.

3) Notes:
App_offline.htm cannot be smaller than 512 bytes
IIS cannot stop. Itpub personal space

3. Only requests for the. aspxfile are automatically transferred to the app_offline.htmfile. If the request is a file such as .htm and .asp, it will not be transferred to the app_offline.htm file.

Hosts file.

4. If you are happy, you can write your own code to process client requests, intercept all requests, and switch to a prompt page.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.