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

推荐订阅源

WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
腾讯CDC
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
N
Netflix TechBlog - Medium
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
GbyAI
GbyAI
B
Blog
F
Fortinet All Blogs
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
Google Developers Blog
A
About on SuperTechFans
C
Check Point Blog
Microsoft Security Blog
Microsoft Security Blog
MyScale Blog
MyScale Blog
B
Blog RSS Feed

博客园 - 融化了的朱古力

AJAX Automated Testing Object design Online dictionary ASP.NET 2.0服务器控件与组件开发高级编程 Professional asp.net 2.0 Server Control and Component Development .NET组件程序设计 .NET组件程序设计0723 .NET组件程序设计0721 .NET组件程序设计 never draw to an inside straight Per say Agile Principles, Patterns, and Practices in C# MapControl MapPoint Helpful Links 20060827 20060812 what is locality of reference? 20060806 20060802
Professional asp.net 2.0 server control and component dev...
融化了的朱古力 · 2007-10-10 · via 博客园 - 融化了的朱古力

P653 Listing 21-21

void OnLogin(object sender, EventArgs e)
{
if (CustomComponents.Membership.ValidateUser(userNameTextBox.Text,
passwordTextBox.Text))
{
FormsAuthenticationTicket ticket 
= new FormsAuthenticationTicket( 1,
userNameTextBox.Text, DateTime.Now,
DateTime.Now.AddSeconds(
40),falsestring.Empty);
string encryptedTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie 
= new HttpCookie(FormsAuthentication.FormsCookieName);
cookie.Value 
= encryptedTicket;
Page.Response.Cookies.Add(cookie);
EnsureChildControls();
Page.Response.Redirect(
FormsAuthentication.GetRedirectUrl(userNameTextBox.Text, 
false), true);
}

}

对于EnsureChildControls()的调用,作者解释:

The OnLogin method calls the EnsureChildControls method before the call into the Redirect method because it passes the value of the Text property of the username TextBox into the Redirect method. Recall that every composite
control must call the EnsureChildControls method before it attempts to access its child controls:

但是之前的代码早已经access its child controls了。奇怪。

if (CustomComponents.Membership.ValidateUser(userNameTextBox.Text,
passwordTextBox.Text))