大家帮我看看。。账号没有输入是怎么通过验证的。
大家帮我看看。。账号没有输入是怎么通过验证的,
运行时为什么只有TextBox3.text有一值。。textBox1,textbox2都没有值
Web.config文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<authentication mode="Forms">
<forms name="eshop" loginUrl="signIn.aspx" protection="All" path="/" />
</authentication>
<customErrors mode="RemoteOnly" defaultRedirect="Error.aspx">
</customErrors>
<compilation
defaultLanguage="c#"
debug="true"
/>
</system.web>
<location path="WebForm1.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>
Webform页面代码:
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
System.Web.HttpContext context = System.Web.HttpContext.Current;
// 如果用户已通过验证,则返回其用户编号作为CartId
if (context.User.Identity.Name != "")
{
TextBox1.Text= context.User.Identity.Name.ToString();
}
// 如果请求用户为匿名,则创建临时的CartId
if (context.Request.Cookies["eshop_CartID"] != null)
{
TextBox2.Text= context.Request.Cookies["eshop_CartID"].Value.ToString();
}
else
{
// 生成GUID
Guid tempCartId = Guid.NewGuid();
// 将GUID保存到Cookie
context.Response.Cookies["eshop_CartID"].Value = tempCartId.ToString();
// 返回临时CartId
TextBox3.Text= tempCartId.ToString();
}
}