Reputation: 447
I have a ASPX C# web application that I'm trying to migrate over to a test server. The web application works perfect on my live server, but I'm running into the following error when trying to run on my test server. I copied over the project source code.
When I try to browse the site from the local machine I get the following error message (for security reasons I'm changing the name of the environment variable I'm calling it 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
First thing I did was set up that environment variable exactly how it is on my live site. Same spelling and file path. Now in my CMD
if I echo out that variable I get back: C:\ThisVariable
In my web.config
file I found this line here:
<file type="log4net.Util.PatternString" value="%env{ThisVariable}\Logs\ThisVariable.City.Web.Application.Test" />
In the ApplicationException
error log it references a path on my D drive, but there is nothing in my D drive. I do however have a Global.asax
in my project folder, but it is only one line long containing this code:
<%@ Application Codebehind="Global.asax.cs" Inherits="ThisVariable.City.Web.Application.Test.Global" Language="C#" %>
Any ideas?
Upvotes: 1
Views: 1882
Reputation: 26342
Not having the full picture on whether these are user or system environmental variables, my first assumption is that these are user variables: What is the difference between user variables and system variables?
If that's the case, then check here: IIS doesn't use user environment variables
If you want to use user specific environment variables, then the application pool setting LoadUserProfile should be set to true (false is the default),
Otherwise, set the system variable and restart iis, or if that fails, restart the machine.
Upvotes: 1