Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

How to modify servervariables?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sanjib Biswas - 17 Feb 2008 09:25 GMT
Hi,

  I have an ASP.Net application which talks to an ASP application. As the
ASP.Net application talk to the ASP application, the REMOTE_ADDR server
variable points to the IP address of the ASP.Net application. I would like
to modify server variables to point to the actual client IP address rather
than ASP.Net application.

Client -> ASP.Net (Web application) -> ASP (Web application)

Request.ServerVariables["REMOTE_ADDR"] = clientIP;

Above code is throwing an exception.

[PlatformNotSupportedException: Operation is not supported on this
platform.]
  System.Web.HttpServerVarsCollection.Set(String name, String value)
+3254625
  System.Collections.Specialized.NameValueCollection.set_Item(String name,
String value) +9

I have also tried

Request.ServerVariables.Remove("remote_addr");
Request.ServerVariables.Add("REMOTE_ADDR", clientIP);

This code throws "Cannot directly modify server variables". Any idea how to
tackle this problem?

Thanks,
Sanjib
Alexey Smirnov - 17 Feb 2008 11:21 GMT
On Feb 17, 10:25 am, "Sanjib Biswas" <Sanjib.Bis...@pointerltd.com>
wrote:
> Hi,
>
[quoted text clipped - 7 lines]
>
> Request.ServerVariables["REMOTE_ADDR"] = clientIP;

First of all, I think you logic is wrong here. I guess, you get the
"incorrect" IP on the ASP side and not in the ASP.NET application,
where Request.ServerVariables["REMOTE_ADDR"] is already equal to
clientIP and

Request.ServerVariables["REMOTE_ADDR"] = clientIP;

makes no sense to me. Maybe you should try to pass this ip via
querystring to ASP. For example,

Client requests "default.aspx"
->
ASP.Net (Web application) takes an IP and call "default.asp?from_ip="
+ IP
->
ASP (Web application) takes the IP from the "from_ip" value

Regarding HttpRequest.ServerVariables Property, it's by design
"***gets*** a collection of Web server variables"
http://msdn2.microsoft.com/en-us/library/system.web.httprequest.servervariables(
VS.80).aspx


Hope this helps

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.