【发布时间】:2021-01-07 19:51:07
【问题描述】:
我有一个 ASPX C# Web 应用程序,我正在尝试将它迁移到测试服务器。 Web 应用程序在我的实时服务器上运行良好,但在我的测试服务器上运行时遇到了以下错误。我复制了项目源代码。
当我尝试从本地计算机浏览该站点时,我收到以下错误消息(出于安全原因,我正在更改环境变量的名称,我将其称为 ThisVariable):
ThisVariable environment variable not set.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ApplicationException: ThisVariable environment variable not set.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
[ApplicationException: ThisVariable environment variable not set.]
ThisVariable.Common.Configuration.BaseConfiguration.GetThisVariableHome() +203
ThisVariable.Common.Configuration.BaseConfiguration.Initialize(String configFileName) +84
ThisVariable.City.Web.Application.Test.Global.Application_Start(Object sender, EventArgs e) in D:\Src\Tfs\Customers\City\Test\Source\DotNet\Application\Web\TestWebApplication\Global.asax.cs:17
我做的第一件事就是准确地设置环境变量在我的实时站点上的样子。相同的拼写和文件路径。现在在我的CMD 中,如果我回显那个变量,我会返回:C:\ThisVariable
在我的web.config 文件中,我在这里找到了这一行:
<file type="log4net.Util.PatternString" value="%env{ThisVariable}\Logs\ThisVariable.City.Web.Application.Test" />
在ApplicationException 错误日志中,它引用了我的 D 驱动器上的路径,但我的 D 驱动器中没有任何内容。但是,我的项目文件夹中确实有一个 Global.asax,但它只有一行包含此代码:
<%@ Application Codebehind="Global.asax.cs" Inherits="ThisVariable.City.Web.Application.Test.Global" Language="C#" %>
有什么想法吗?
【问题讨论】:
标签: c# asp.net web-applications