Microsoft Office Online
Sign in to My Office Online (What's this?) | Sign in

Warning: You are viewing this page with an unsupported Web browser. This Web site works best with Microsoft Internet Explorer 6.0 or later, Firefox 1.5, or Netscape Navigator 8.0 or later. Learn more about supported browsers.

Email this linkEmail this link Printer-Friendly VersionPrinter-Friendly Version Bookmark and ShareShare
Password-protect an ASP page
 

If you have information on an ASP (Active Server Pages) page that you only want certain users to have access to, creating a password that you give out to a limited number of people is a great way to help protect that information.

The following procedure assumes that the Web page you want to assign a password to has the .asp extension. In most cases, it's possible to rename Web pages that have .htm or .html extensions with .asp extensions. Exceptions include:

  • Any files located on Web servers that do not support Active Server Pages.
  • Certain files with .htm or .html extensions that render dynamic content.

If you are uncertain whether your file can safely be renamed with an .asp extension, consult your Web server administrator or Internet service provider.

Password-protect your active server page

Notes

  • Basic knowledge of Hypertext Markup Language (HTML) is helpful when following this procedure.
  • To save time, you can copy and paste the sample code in this article. However, you cannot do it directly from this article into Microsoft FrontPageĀ®; you will need to copy the code, paste it into a Microsoft Notepad document and then paste it from Notepad into FrontPage.
  1. Make sure the Web page you want to work with has an .asp extension. If it doesn't, rename it:
    • If the Folder List isn't showing, click the arrow to the right of the Toggle Pane and select Folder List.
    • In the Folder List, right-click the file or folder you want to rename, and then click Rename on the shortcut menu.
    • Select the extension and replace it with .asp
  2. Open the Web page.
  3. In Page view, click the HTML button.
  4. In the HTML pane, before the first line of code, press ENTER to create a new line.
  5. In the new line you just created, type the following:
     <% Response.Buffer=true %>
    
  6. Find the opening <body> tag.
  7. On the line following the <body> tag, type the following:
    
    <% If Request.Form("pw") = "SECURE" Then %>
    
    
  8. Change SECURE to your own password. You can use uppercase and lowercase letters, numbers, and other characters, in any combination.

  9. Find the closing </body> tag. It should be near the bottom of the page.
  10. Place your insertion point before the </body> tag and press ENTER. A new line is created above </body>.
  11. Beginning on the new line you just created, type the following.
    <% Else
    Response.Write "To view this page, enter a valid password." & _
    "<FORM ACTION=""thispage.asp"" METHOD=""POST"">" & _
    "<INPUT SIZE=10 TYPE=""password"" NAME=""pw"">" & _
    "<INPUT TYPE=""submit"" NAME=""Submit"" VALUE=""Go"">"  & _
    "</FORM>"
    End If %>
    
  12. Rename thispage to the name of the current Web page.
  13. Click Save.

Anyone who wants access to this page will now have to enter the password you specified in order to view it.

More information

For more information about creating Active Server Pages with FrontPage, see Microsoft FrontPage Help.

© 2009 Microsoft Corporation. All rights reserved.