Skip to content

Instantly share code, notes, and snippets.

@masaru-b-cl
Created February 27, 2012 01:53
Show Gist options
  • Save masaru-b-cl/1920667 to your computer and use it in GitHub Desktop.
Save masaru-b-cl/1920667 to your computer and use it in GitHub Desktop.
MinimamFormAuthenticationSample
bin/
obj/
*.user
*.suo
TestResults/
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<header>
<h1>サンプルシステム</h1>
</header>
<article>
<h2>サンプルシステムにようこそ!</h2>
<ol>
<li><a href="#">○○マスターメンテナンス</a></li>
<li><a href="#">□□マスターメンテナンス</a></li>
</ol>
</article>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LoginInner.aspx.cs" Inherits="LoginInner" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>
内部用ログイン
</h1>
<asp:Login ID="Login1" runat="server" OnAuthenticate="Login1_Authenticate">
</asp:Login>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class LoginInner : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
// 本気認証はここで
e.Authenticated = true;
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LoginOuter.aspx.cs" Inherits="LoginOuter" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>
外部用ログイン
</h1>
<asp:Login ID="Login1" runat="server" OnAuthenticate="Login1_Authenticate">
</asp:Login>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class LoginOuter : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
// 本気認証はここで
e.Authenticated = true;
}
}

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Web Developer Express 2010
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "localhost", "http://localhost:15459", "{F9DDBD1D-CCB2-46DA-95CC-83403A182502}"
ProjectSection(WebsiteProperties) = preProject
UseIISExpress = "true"
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0"
Debug.AspNetCompiler.VirtualPath = "/localhost_15459"
Debug.AspNetCompiler.PhysicalPath = "LoginSampleSite\"
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_15459\"
Debug.AspNetCompiler.Updateable = "true"
Debug.AspNetCompiler.ForceOverwrite = "true"
Debug.AspNetCompiler.FixedNames = "false"
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.VirtualPath = "/localhost_15459"
Release.AspNetCompiler.PhysicalPath = "LoginSampleSite\"
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_15459\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "false"
Release.AspNetCompiler.Debug = "False"
SlnRelativePath = "..\..\WebSites\LoginSample\LoginSampleSite\"
DefaultWebSiteLanguage = "Visual C#"
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F9DDBD1D-CCB2-46DA-95CC-83403A182502}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9DDBD1D-CCB2-46DA-95CC-83403A182502}.Debug|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0"?>
<!--
ASP.NET アプリケーションを構成する方法の詳細については、
http://go.microsoft.com/fwlink/?LinkId=169433 を参照してください
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Forms">
<forms loginUrl="LoginOuter.aspx"/>
<!--
ログインフォームを切り替える時は、loginUrl属性を変更する
<forms loginUrl="LoginInner.aspx"/>
<forms loginUrl="LoginOuter.aspx"/>
-->
</authentication>
<authorization>
<!-- 匿名ユーザー(未認証のユーザー)はWebサイト参照不可 -->
<deny users="?" />
</authorization>
</system.web>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment