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

推荐订阅源

WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
V
Visual Studio Blog
宝玉的分享
宝玉的分享
IT之家
IT之家
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
I
InfoQ
B
Blog RSS Feed
T
Threatpost
博客园_首页
M
MIT News - Artificial intelligence
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Know Your Adversary
Know Your Adversary
U
Unit 42
Engineering at Meta
Engineering at Meta
C
Cyber Attacks, Cyber Crime and Cyber Security
月光博客
月光博客
Scott Helme
Scott Helme
T
Tor Project blog
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Last Week in AI
Last Week in AI
S
Schneier on Security
Vercel News
Vercel News
博客园 - Franky
C
Cybersecurity and Infrastructure Security Agency CISA
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
L
LangChain Blog
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
Latest news
Latest news
C
CXSECURITY Database RSS Feed - CXSecurity.com
Hugging Face - Blog
Hugging Face - Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
S
Security Affairs
A
About on SuperTechFans
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
大猫的无限游戏
大猫的无限游戏
W
WeLiveSecurity
Cisco Talos Blog
Cisco Talos Blog
罗磊的独立博客

博客园 - DongD

今天在ASP.NET上在写一个读取EXCEL文件内容的功能,但是IE8貌似把文件路径给屏蔽了,在IE6下面读取正常!有啥好办法? 刚看了一点Spring .NET, 从第一个例子MovieFinder说起(2) 刚看了一点Spring .NET, 从第一个例子MovieFinder说起 RegularExpressionValidator控件中正则表达式用法[转] 一个计算周次和本周时间范围的代码(c#) ASP.NET 安全认证(二)【转】 Host and Workflow: Two Worlds to Communicate: Part III Host and Workflow: Two Worlds to Communicate - Part II Host and Workflow: Two Worlds to Communicate: Part I .NET2.0正则表达式【转】 解决Active Directory密码不满足密码策略的要求 Gridview控件中字符串的截取【转】 asp.net(c#)常用正则表达式实例 C#中的delegate和event 【转】 Asp.net &C#开发中的一些注意事项及小技巧【转】 C# 事件机制【转】 asp.net中为TextBox Web服务器控件添加OnClick事件【转】 gridview在绑定显示的各种格式 跳楼有感【转载】
ASP.NET 的安全认证 - DongD - 博客园
DongD · 2009-12-09 · via 博客园 - DongD

ASP.NET 的安全认证,共有“Windows”“Form”“Passport”“None”四种验证模式。

运用Form表单进行ASP.NET认证

把下面的代码

<!--<authentication mode="Windows"/>-->

修改为

<authentication mode="Forms">
      
<forms name=".ASP.NET.COOKIE.SZMEDI" loginUrl="Log.aspx" protection="All" timeout="30" path="/"/>
</authentication>

<authorization>
      <deny user="?"></deny>
</authorization>

.cs 代码——登录与退出

登录代码:

a、  书本上介绍的

代码

private void Btn_Login_Click(object sender, System.EventArgs e)
{
     
if(this.Txt_UserName.Text=="Admin" && this.Txt_Password.Text=="123456")
     {
         System.Web.Security.FormsAuthentication.RedirectFromLoginPage(
this.Txt_UserName.Text,false);
     }
}

 b

代码

private void Btn_Login_Click(object sender, System.EventArgs e)
{
     
if(this.Txt_UserName.Text=="Admin" && this.Txt_Password.Text=="123456")
     { 
          System.Web.Security.FormsAuthentication.SetAuthCookie(
this.Txt_UserName.Text,false);
          Response.Redirect(
"Default.aspx");
     }
}

以上两种都可发放验证后的 Cookie ,即通过验证,区别:

方法 a) 指验证后返回请求页面,俗称“从哪来就打哪去”。比如:用户没登录前直接在 IE 地址栏输入 http://localhost/FormTest/UserInfo.aspx ,那么该用户将看到的是 Login.aspx?ReturnUrl=UserInfo.aspx ,输入用户名与密码登录成功后,系统将根据“ReturnUrl”的值,返回相应的页面

方法 b) 则是分两步走:通过验证后就直接发放 Cookie ,跳转页面将由程序员自行指定,此方法多用于 Default.aspx 使用框架结构的系统。

退出代码:

private void Btn_LogOut_Click(object sender, System.EventArgs e)
{
     System.Web.Security.FormsAuthentication.SignOut();
}

 如何判断验证与否及获取验证后的用户信息

有的时候,在同一张页面需要判断用户是否已经登录,然后再呈现不同的布局。有人喜欢用 Session 来判断,我不反对此类做法,在此我只是想告诉大家还有一种方法,且看下面代码:

if(User.Identity.IsAuthenticated)
{
   
//你已通过验证,知道该怎么做了吧?
}

User.Identity 还有两个属性AuthenticationType(验证类型)与 Name(用户名称) ,大家要注意的是 Name 属性,此处的User.Identity.Name将得到,验证通过(RedirectFromLoginPage SetAuthCookie)时,我们带入的第一个参数 this.Txt_UserName.Text

Web.config 的作用范围

新建项目时, VS.Net 会在项目根目录建立一个内容固定的 Web.config。除了在项目根目录,你还可以在任一目录下建立 Web.config ,条件就是应用程序级别的节点只能在根目录的 Web.config 中出现。

关于 Web.config 设置的作用范围,记住以下两点:

1、  Web.config 的设置将作用于所在目录的所有文件及其子目录下的所有东东(继承:子随父姓)

2、  子目录下的 Web.config 设置将覆盖由父目录继承下来的设置(覆盖:县官不如现管)

学会拒绝与巧用允许


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/cityhunter172/archive/2005/11/06/524043.aspx