Created
December 15, 2014 11:53
-
-
Save uniquelau/a92dd9ca2248959a0d5d to your computer and use it in GitHub Desktop.
Password Protect Azure Website
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page Language="C#" %> | |
<%@ Import Namespace="System.Web.Security" %> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<script runat="server"> | |
public void Login_OnClick(object sender, EventArgs args) | |
{ | |
if (FormsAuthentication.Authenticate(UsernameTextbox.Text, PasswordTextbox.Text)) | |
FormsAuthentication.RedirectFromLoginPage(UsernameTextbox.Text, NotPublicCheckBox.Checked); | |
else | |
Msg.Text = "Login failed. Please check your user name and password and try again."; | |
} | |
</script> | |
<html xmlns="http://www.w3.org/1999/xhtml" > | |
<head> | |
<title>Login</title> | |
</head> | |
<body> | |
<form id="form1" runat="server"> | |
<h3>Login</h3> | |
<asp:Label id="Msg" ForeColor="maroon" runat="server" /><br /> | |
Username: <asp:Textbox id="UsernameTextbox" runat="server" /><br /> | |
Password: <asp:Textbox id="PasswordTextbox" runat="server" TextMode="Password" /><br /> | |
<asp:Button id="LoginButton" Text="Login" OnClick="Login_OnClick" runat="server" /> | |
<asp:CheckBox id="NotPublicCheckBox" runat="server" /> | |
Check here if this is <span style="text-decoration:underline">not</span> a public computer. | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<configuration> | |
<system.web> | |
<compilation debug="false" /> | |
<authentication mode="Forms"> | |
<forms> | |
<credentials passwordFormat="Clear"> | |
<user name="user" password="password" /> | |
</credentials> | |
</forms> | |
</authentication> | |
<!-- Unless specified in a sub-folder's Web.config file, | |
any user can access any resource in the site --> | |
<authorization> | |
<deny users="?" /> | |
</authorization> | |
</system.web> | |
<system.webServer> | |
<modules> | |
<remove name="FormsAuthenticationModule" /> | |
<add name="FormsAuthenticationModule" type="System.Web.Security.FormsAuthenticationModule" /> | |
<remove name="UrlAuthorization" /> | |
<add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" /> | |
</modules> | |
</system.webServer> | |
</configuration> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment