c# - How to Test ASP.NET Application That Depends on IP Address -
I have written an asp.net application, and in this application I log the IP address requested. And I also provide different content according to different IP category.
My question is, in my limited test environment, I have only 5 machines, each machine has only 1 IP address, I want to fully test my ASP.NET based on IP address , How should I prepare the HTTP request in my case, including the arbitrary IP address of the 5 IP addresses of my test machines?
Solution. Net / C # is appreciated. But any current tool is appreciated.
EDIT1: I am writing a school education web application which provides different content to students of different cities. There are different sections / seminars / training in various cities and I want to display the most amazing material according to the school's proxy address in the specific city.
An option to change your logic to see an IP address or header. This header is often used to indicate the requested IP address through a proxy server, though, you do not need to keep the proxy in mind here, but by doing so you can test your logic. Very easy to provide the way.
I think that instead of trying to deceive this IP address it will be your quick route.
edit
Uri uriObj = new Uri ("http: // localhost"); HttpWebRequest Request = (HttpWebRequest) WebRequest.CreateDefault (uriObj); Request.Headers.Add ("X-Forward-To", "125.125.125.125"); WebResponse response = Request GetResponse (); StreamerMinder Reader = New Streamerder (ReactionGetterSponsScream ()); Console.WriteLine (reader.ReadToEnd ()); edit
You need to change your server side logic:
string ip = Request Header. Get ("x-forward-for"); If (string.IsNullOrEmpty (ip)) {ip = Request.UserHostAddress; } It basically says that the header is included, then use it otherwise they use the IP address I told to them. This way your test code and actual users will be picked up.
Comments
Post a Comment