可以用下面的语句试试看:
Private Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs)Handles MyBase.Unload
//删除文件的语句
End Sub

解决方案 »

  1.   

    <html>
    <head>
    <SCRIPT event="onunload" for="window">
     if (event.clientX <0 && event.clientY <0 )
     window.open('xxx.aspx','','height=100,width=100,top=0,scrollbar=no,sstatus=no,titlebar=no,toolbar=no,menubar=no,location=no');
                             
    </SCRIPT>
    </head>
    <body>
    </body>在xxx.aspx的page_load中添加删除文件的语句,并且关闭自身
      

  2.   

    在global.asax里面加上你的代码
    protected void Application_End(Object sender, EventArgs e)
    {
      Application["StartIndex"] = 0;
    //删除文件
    if(File.Exists(Server.MapPath("aa.txt"))
    File.Delete(Server.MapPath("aa.txt"));
    }
      

  3.   

    <html>
    <head>
    <SCRIPT >
       function DelFile(){
            __DoPostBack('你定义的隐藏按钮ID','');   }                         
    </SCRIPT>
    </head>
    <body onunload="DelFile()"></body>按钮的事件响应为你的删除功能,Visable=false就行了。试一下吧