IIS
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationIIS

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 5th, 2008, 03:55 PM
theallan theallan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 1 theallan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 19 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old July 9th, 2008, 10:48 PM
PWD's Avatar
PWD PWD is offline
Network Engineer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2004
Location: 127.0.0.1
Posts: 709 PWD User rank is First Lieutenant (10000 - 20000 Reputation Level)PWD User rank is First Lieutenant (10000 - 20000 Reputation Level)PWD User rank is First Lieutenant (10000 - 20000 Reputation Level)PWD User rank is First Lieutenant (10000 - 20000 Reputation Level)PWD User rank is First Lieutenant (10000 - 20000 Reputation Level)PWD User rank is First Lieutenant (10000 - 20000 Reputation Level)PWD User rank is First Lieutenant (10000 - 20000 Reputation Level)PWD User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 23 h 45 m 56 sec
Reputation Power: 190
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!

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationIIS > Reading an environment variable


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT