惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
博客园 - 三生石上(FineUI控件)
爱范儿
爱范儿
博客园 - 聂微东
V
Visual Studio Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
M
MIT News - Artificial intelligence
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
有赞技术团队
有赞技术团队
L
LangChain Blog
I
InfoQ
T
Tailwind CSS Blog
博客园 - 【当耐特】
V
V2EX
博客园_首页
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
GbyAI
GbyAI
Vercel News
Vercel News
雷峰网
雷峰网
量子位
A
About on SuperTechFans
Martin Fowler
Martin Fowler
H
Help Net Security

博客园 - 00654

阳光已经好久不见 我这里有漂亮的繁体字,非主流图片 编写第一个JavaScript程序 - 00654 - 博客园 sql语句实现模糊搜索 反回上一页并刷新! - 00654 - 博客园 自己写的一个分页代码。写得不好哈! 取得页面执行时间的代码 - 00654 - 博客园 Java脚本提示用户是否确定操作。否则取消当前操作。 - 00654 - 博客园 checkbox控件.全选与不全选的切换 - 00654 - 博客园 用JavaScript判断用户输入的数据是否如何要求! - 00654 - 博客园 [asp.net]Forms验证初步 SQL SERVER 函数 Scott Mitchell的ASP.NET2.0数据指南中文版索引 (好教程) Asp.Net 函数,方法。不断添加中。。 ASP.Net中控件的EnableViewState属性 ObjectDataSource控件的使用... Sql存储过程和函数集合.(不断更新中....) Select嵌套查询.(子查询取得其他表字段的值.并显示在本次查询的结果) DateReader,DateAdapter,DateSet和SqlCommand的基本使用方法
用Forms做管理员登陆。。。
00654 · 2006-12-19 · via 博客园 - 00654
 

//判断用户名是否正确。。
string User,Pass;
        User=user.Text;
        Pass=pass.Text;
        Iindex iindex = new index();
        if (User == ""){ Label1.Text = "管理员用户名不能为空!"; }
        else
        {
            if (Pass == "") { Label1.Text = "管理员密码不能为空!"; }
            else
            {
                if (iindex.admingo(User, Pass))
                { FormsAuthentication.RedirectFromLoginPage(User, false); } //正确。允许访问保护文件。
                    
                else
                {
                    Label1.Text = "登陆失败.请确认用户和密码是否输入正确!";
                }
            }
        }

HttpContext.Current.User.Identity.Name; //得到当前登陆的用户名。。
System.Web.Security.FormsAuthentication.SignOut();  注销登陆 

web.config文件配置。

<?xml version="1.0"?>
<!--
    注意: 除了手动编辑此文件以外,您还可以使用
    Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
     “网站”->“Asp.Net 配置”选项。
    设置和注释的完整列表在
    machine.config.comments 中,该文件通常位于
    \Windows\Microsoft.Net\Framework\v2.x\Config 中
-->
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
 <connectionStrings>
  <add name="Data" connectionString="Data Source=127.0.0.1;Initial Catalog=Sf00654;User ID=sa;Password=4501550"
   providerName="System.Data.SqlClient" />
 </connectionStrings>
 <appSettings/>
 <system.web>
  <compilation debug="true"/>
    <!--=========================================================================================设置为窗体身份验证方式...-->
    <authentication mode="Forms" >
      <forms loginUrl="Admin/index.aspx" protection="All" timeout="360" name=".ASPX00654" requireSSL="false" cookieless="UseDeviceProfile" defaultUrl="admin/admin_index.aspx">
      </forms>
    </authentication>
    <!--=========================================================================================-->
  </system.web>
  <location path="Admin">  <!--受保护的文件夹-->
    <system.web>
      <authorization>
        <deny users="?"></deny>
        <!--这是一个授权节,此节设置应用程序的授权策略。可以允许(allow)或拒绝(deny)不同的用户或角色访问应用程序资源。
        通配符: "*" 表示任何人,"?" 表示匿名(未经身份验证的)用户。看我们上面的设置知道,这样配置就是拒绝未经身份验证的用户访问。-->
      </authorization>
    </system.web>
  </location>
  <!--=========================================================================================-->
</configuration>