⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 global.asax

📁 Get Map Coordinat by click on map
💻 ASAX
字号:
<%@ Application Language="VB" %>

<%--
//////////////////////////////////////////////////////////////////////////////////////////////
//
//   (c) Pitney Bowes MapInfo Corporation, 2008.  All rights reserved.
//
//   This software is only provided as a demonstration by MapInfo.  
//   No licence or other right is granted.  
//   No use, transmission or copying is permitted.
//
//   This software is provided by MapInfo "as is" and any express or implied warranties, 
//   including, but not limited to, the implied warranties of merchantability and fitness 
//   for a particular purpose are disclaimed.  In no event shall MapInfo be liable for any 
//   direct, indirect, incidental, special, exemplary, or consequential damages (including, 
//   but not limited to, procurement of substitute goods or services; loss of use, data or
//   profits; or business interruption) however caused and whether in contract, strict 
//   liability, or tort (including negligence) arising in any way out of the use of this 
//   software, even if advised of the possibility of such damage.
//
//////////////////////////////////////////////////////////////////////////////////////////////--%>

<script runat="server">

    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs on application startup
    End Sub
    
    Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs on application shutdown
    End Sub
        
    Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs when an unhandled error occurs
        Dim ex As Exception = Server.GetLastError()
        If Not ex Is Nothing And ex.Message.Length > 0 Then
            ' If the request was for the map image then write the messages into a bitmap and send it back.
            If HttpContext.Current.Request.Url.AbsoluteUri.IndexOf("MapController") >= 0 Then
                ' Get height and width from the request if it was a request for map image.
                Dim mapWidth As Integer = System.Convert.ToInt32(HttpContext.Current.Request(MapInfo.WebControls.MapBaseCommand.WidthKey))
                Dim mapHeight As Integer = System.Convert.ToInt32(HttpContext.Current.Request(MapInfo.WebControls.MapBaseCommand.HeightKey))

                Dim builder1 As StringBuilder = New StringBuilder
                Dim b As System.Drawing.Bitmap = New System.Drawing.Bitmap(mapWidth, mapHeight)
                Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(b)

                ' Append the message from exception
                builder1.Append(ex.Message)
                builder1.Append(System.Environment.NewLine)

                ' Create stack trace for exception
                Dim st As System.Diagnostics.StackTrace = New Diagnostics.StackTrace(ex, True)
                Dim num2 As Integer
                For num2 = 0 To st.FrameCount - 1 Step num2 + 1
                    Dim frame1 As Diagnostics.StackFrame = st.GetFrame(num2)
                    Dim base1 As Reflection.MethodBase = frame1.GetMethod()
                    Dim type1 As Type = base1.DeclaringType
                    Dim text1 As String = String.Empty
                    If Not type1 Is Nothing Then
                        text1 = type1.Namespace
                    End If
                    If Not text1 Is Nothing Then
                        If text1.Equals("_ASP") Or text1.Equals("ASP") Then
                            'this._fGeneratedCodeOnStack = true;
                        End If
                        text1 = text1 + "."
                    End If
                    If type1 Is Nothing Then
                        builder1.Append("   " + base1.Name + "(")
                    Else
                        Dim textArray1() As String = New String() {"   ", text1, type1.Name, ".", base1.Name, "("}

                        builder1.Append(String.Concat(textArray1))
                    End If
                    Dim infoArray1() As Reflection.ParameterInfo = base1.GetParameters()
                    Dim num3 As Integer
                    For num3 = 0 To infoArray1.Length - 1 Step num3 + 1
                        Dim tmp As String
                        If (num3 <> 0) Then
                            tmp = ","
                        Else
                            tmp = ""
                        End If
                        builder1.Append(tmp + infoArray1(num3).ParameterType.Name + " " + infoArray1(num3).Name)
                    Next
                    builder1.Append(")")
                    builder1.Append(System.Environment.NewLine)
                Next

                ' write the strings into the rectangle
                g.DrawString(builder1.ToString(), New Drawing.Font("Tahoma", 7), New Drawing.SolidBrush(System.Drawing.Color.Yellow), New Drawing.RectangleF(0, 0, mapWidth, mapHeight), System.Drawing.StringFormat.GenericDefault)

                ' Save the bitmap into the stream to send it back
                Dim contentType As String = String.Format("text/HTML")
                If Not contentType Is Nothing Then
                    HttpContext.Current.Response.ContentType = contentType
                End If
                b.Save(HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif)

                ' End the response here
                HttpContext.Current.Response.End()
            Else
                ' Let the exception pass through
            End If
        End If
	End Sub

    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs when a new session is started
    End Sub

    Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs when a session ends. 
        ' Note: The Session_End event is raised only when the sessionstate mode
        ' is set to InProc in the Web.config file. If session mode is set to StateServer 
        ' or SQLServer, the event is not raised.
    End Sub
       
</script>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -