我定义了一个
private void pp()
{
HttpContext.Current.Session["Code"] = "TraditionalChinese";
Response.Redirect(Request.RawUrl);
}加载的时候if(!Page.IsPostBack)
{
pp();
}
打开页面的时候发现页面在不停的加载 重定位我用一个Button
private void Button1_Click(object sender, System.EventArgs e)
{
pp();
}
页面就不会不停重定位 请问是怎么回事啊?
private void pp()
{
HttpContext.Current.Session["Code"] = "TraditionalChinese";
Response.Redirect(Request.RawUrl);
}加载的时候if(!Page.IsPostBack)
{
pp();
}
打开页面的时候发现页面在不停的加载 重定位我用一个Button
private void Button1_Click(object sender, System.EventArgs e)
{
pp();
}
页面就不会不停重定位 请问是怎么回事啊?
而直接打开页面时IsPostBack=false然后自己想想吧
---页面是否为第一次加载,当使用者第一次浏览这个网页时Page.IsPostBack 会传回False,不是第一次浏览这个网页时就传回True
Response.Redirect(Request.RawUrl);
你这样不是都是第一次访问吗
如:
private void pp()
{
HttpContext.Current.Session["Code"] = "TraditionalChinese";
Response.Redirect(Request.RawUrl);Response.Write("12121212");Response.End();
}还是一样 页面打开不停的重载
Response.Redirect(Request.RawUrl),就是一直在重新打开这个页面。相当于死循环!
IsPostBack是判断有没有向服务器提交数据。
你最好能看一看MSDN
说的很对因为你每一次进那个页面都是!Page.IsPostBack
Response.Redirect(Request.RawUrl);
你这样不是都是第一次访问吗
那怎么解决呢? 我想得到的效果是 打开页面不用点击Button 就有HttpContext.Current.Session["Code"] = "TraditionalChinese";
Response.Redirect(Request.RawUrl);
加载一次的效果