seehttp://samples.gotdotnet.com/quickstart/aspplus/doc/globalasax.aspx

解决方案 »

  1.   

    我看了把他的源码拷上去依旧报错,请替我看看错在何处,为什么错?代码付上。请指点,谢谢!
    Global.asax.vbImports System.Web
    Imports System.Web.SessionStatePublic Class Global
        Inherits System.Web.HttpApplication#Region " 组件设计器生成的代码 "    Public Sub New()
            MyBase.New()        '该调用是组件设计器所必需的。
            InitializeComponent()        '在 InitializeComponent() 调用之后添加任何初始化    End Sub    '组件设计器所必需的
        Private components As System.ComponentModel.IContainer    '注意:以下过程是组件设计器所必需的
        '可以使用组件设计器修改此过程。
        '不要使用代码编辑器修改它。
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            components = New System.ComponentModel.Container()
        End Sub#End Region   <script language="VB" runat="server">    Sub Application_Start(ByVal Sender As Object, ByVal E As EventArgs)
            ' Do application startup code here
        End Sub    Sub Application_End(ByVal Sender As Object, ByVal E As EventArgs)
            ' Clean up application resources here
        End Sub    Sub Session_Start(ByVal Sender As Object, ByVal E As EventArgs)
            Response.Write("Session is Starting...<br>")
        End Sub    Sub Session_End(ByVal Sender As Object, ByVal E As EventArgs)
            ' Clean up session resources here
        End Sub    Sub Application_BeginRequest(ByVal Sender As Object, ByVal E As EventArgs)
            Response.Write("<h3><font face='Verdana'>Using the Global.asax File</font></h3>")
            Response.Write("Request is Starting...<br>")
        End Sub    Sub Application_EndRequest(ByVal Sender As Object, ByVal E As EventArgs)
            Response.Write("Request is Ending...<br>")
        End Sub    Sub Application_Error(ByVal Sender As Object, ByVal E As EventArgs)
            Context.ClearError()
            Response.Redirect("errorpage.htm")
        End Sub</script>
    End ClassWebForm1.aspx<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="vbWebApplication1.WebForm1"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>  <script language="VB" runat="server">      Sub Page_Load(Sender As Object, E As EventArgs)
             Response.Write("In Page.Load()...<br>")
          End Sub      Sub Session_Click(Sender As Object, E As EventArgs)
             Session.Abandon()
             Response.Redirect("WebForm1.aspx")
          End Sub      Sub Error_Click(Sender As Object, E As EventArgs)
             throw New Exception()
          End Sub  </script>  <body>    <form runat="server" ID="Form1">
          <input type="submit" Value="Refresh This Page" runat="server" ID="Submit1" NAME="Submit1"/>
          <input type="submit" OnServerClick="Session_Click" Value="End This Session" runat="server" ID="Submit2" NAME="Submit2"/>
          <input type="submit" OnServerClick="Error_Click" Value="Generate An Error" runat="server" ID="Submit3" NAME="Submit3"/><p>
          <hr>
        </form>
        
      </body></html>
    errorpage.htm<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <body>
      This is a sample custom error page that will be displayed to clients anytime an unhandled exception occurs during the 
      current web application. This can be configured via the web.config file.
    </body>
    </html>c:\inetpub\wwwroot\vbWebApplication1\Global.asax.vb(31): 未定义类型“script”。
    c:\inetpub\wwwroot\vbWebApplication1\Global.asax.vb(31): 需要“>”。
    c:\inetpub\wwwroot\vbWebApplication1\Global.asax.vb(63): 需要标识符。
    c:\inetpub\wwwroot\vbWebApplication1\WebForm1.aspx(27): 在服务器元素内,元素“p”缺少结束标记或与元素“form”重叠。
      

  2.   


    把Global.asax.vb中的<script language="VB" runat="server">和</script>删掉
    不需要这个东西
      

  3.   

    在代码文件中就把这行免了吧:<script language="VB" runat="server">
      

  4.   

    为什么?是因为去掉这一句不影响功能还是根本就不能这么写?那为什么无论那本书都是这样,连msdn也是这样。
    请各位指点迷津,谢谢!