|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Reading an environment variable
Hello all,
I'm just starting out with IIS (coming from a Unix background) and I'm having some problems with reading environment variables in a CGI program. The problem appears to center around my use of the System.Environment.GetEnvironmentVariable method to read "HTTP_HOST" etc (I believe I could use the Request object which stores this information it it as well, but I'd like to be able to run the program from the CLI, where the Request object is not available and the compiler would complain about it). I get the following error: Unhandled Exception: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) at System.Security.CodeAccessPermission.Demand() at System.Environment.GetEnvironmentVariable(String variable) at Program.MyClass.fnGetVariable(String sVar) etc So I presume I need to add permissions to the script somewhere which allows my program access to read environment variables. but I have absolutely no idea how to do this. Could some one possibly point me in the right direction please? I'm using IIS7 on Windows Vista, and the program is a C# one. Thanks Allan |
|
#2
|
||||
|
||||
|
Did you install the CGI Module Application Feature when you installed IIS (Control Panel => Programs and Features => Turn Windows Feature on or Off => Internet Information Services => Application Development Features => CGI) and enable the CGI application 'ISAPI and CGI restrictions' in IIS Manager (Control Panel => Administration Tools => Internet Information Services Manager => click the server_name => in the right pane double click 'ISAPI and CGI restrictions' and enable the CGI application => Then map the file type to the 'CGIModule' under 'Handler Mappings')?
__________________
PWD MCSE, MCSA, MCP, Security+ NEW Windows Administration Forum Admin Source ![]() Could REALLY, REALLY, REALLY use you and your issues! |
![]() |
| Viewing: Dev Shed Forums > System Administration > IIS > Reading an environment variable |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|