asp.nst(c#)中
怎么防刷新呢??看了很多人说的
都是从客户端下手
可是我试了,还是不行
那个高手能给我说说么

解决方案 »

  1.   

    弹出一个普通窗口或则是模式窗口,普通窗口中不显示刷新等按钮
    同时在脚本中捕获F5的keyCode ,
    if(event.keyCode==116){  //刷新F5
        event.returnValue=false;
    }
      

  2.   

    客户端不解决根本问题,你可以用front controler,在httphandler中加如判断
    如果某ip再短时间内访问同一个url就禁止掉
      

  3.   

    可以这样,用hashtable保存IP和最后访问时间键值对,每次检索IP和最后时间进行对比  public static Hashtable Filters=new Hashtable();
      
         ..........
        string IP=Request.UserHostAddress;
         Filters.Add(IP,DateTime.Now); if(((DateTime)Filters[IP]).AddSeconds(30)>DateTime.Now)
    this.Response.End();
      

  4.   

    觉得simonw(!simon)、  windinwing(潇笑) 所说的也没有根本解决问题
    把问题简单化,具体化<%@ Page Language="C#"%>
    <%@ Import Namespace="System.Data.SqlClient" %><script runat=server>void Page_Load(Object sender , EventArgs e) 
    {
    SqlConnection conNorthwind;
    string  strInsert;
    SqlCommand cmdInsert; conNorthwind = new SqlConnection( @"Server=localhost;Integrated Security=SSPI;database=Northwind" );
    strInsert = "Insert Products ( ProductName, UnitPrice ) Values ('Milk', 12.45 )";
    cmdInsert = new SqlCommand( strInsert, conNorthwind );
    conNorthwind.Open();
    cmdInsert.ExecuteNonQuery();
    conNorthwind.Close();
    Response.Write("New Product Added!");
    }
    </script>怎么防止首次添加后按刷新,不重复添加记录呢
    不能用检验数据库的方法
      

  5.   

    void Page_Load(Object sender , EventArgs e) 
    {
    SqlConnection conNorthwind;
    string  strInsert;
    SqlCommand cmdInsert; conNorthwind = new SqlConnection( @"Server=localhost;Integrated Security=SSPI;database=Northwind" );
    strInsert = "Insert Products ( ProductName, UnitPrice ) Values ('Milk', 12.45 )";
    cmdInsert = new SqlCommand( strInsert, conNorthwind );
    conNorthwind.Open();
    cmdInsert.ExecuteNonQuery();
    conNorthwind.Close();
             Response.Write("<script>alert('New Product Added');window.location='本页地址';</script>")//或者直接Response.Redirect("本页地址")
    }
      

  6.   

    回 ycc2008(皮皮) ,不知你试过没有
    我把你说的两种方法都试了
    还是不行.
      

  7.   

    哦,如果是重复添加记录,可以使用网页过期
    http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=4617