WebSite到WebApplication转换的问题

时间:2018-07-27 18:55:44

标签: asp.net .net vb.net

我使用Visual Studio 2017将网站转换为Web应用程序,转换后Web应用程序将引发以下错误。此问题有解决方案吗

  

解析器错误消息:文件'/Global.asax.vb'不存在。

源错误:

  

第1行:<%@ Application Inherits =“ WebApplication1.Test.Global”   语言=“ VB” CodeFile =“ Global.asax.vb”%

1 个答案:

答案 0 :(得分:0)

使用空白文档打开NOTEPAD应用程序。

将以下代码粘贴到其中

Option Explicit On
Imports Microsoft.VisualBasic
Imports System.Web.SessionState


Public Class Global_asax
  Inherits System.Web.HttpApplication
  '
  Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    ' Fires when the application is started
  End Sub

  Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
    ' Fires when the session is started
  End Sub

  Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
    ' Fires at the beginning of each request
  End Sub

  Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
    ' Fires upon attempting to authenticate the use
  End Sub

  Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
    ' Fires when an error occurs
  End Sub

  Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
    ' Fires when the session ends
  End Sub

  Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
    ' Fires when the application ends
  End Sub

End Class

在代码所在的应用程序的ROOT文件夹中将文件另存为GLOBAL.ASAX。

接下来哪个文件有错误标记了它:

Line 1: <%@ Application Inherits="WebApplication1.Test.Global" Language="VB" CodeFile="Global.asax.vb" %>

将该行更改为以下内容:

<%@ Application Inherits="WebApplication1.Test.Global" Language="VB" %>

由于未发布任何代码,因此看不到您的某些代码,因此很难立即将其确定下来。

如果按照上述步骤操作,应该可以避免显示的错误。