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