hi guys, i'm totally new to the asp.net mvc stack and i was wondering what happened to the simple Page object and the Request ServerVariables object?
basically what i wanted to do is to pull out the client's pc ip address. but i fail to understand how the current MVC structure has changed all of this.
as far as i can understand, most of the variable object has been replaced by the HttpRequest variants?
anybody care to share some resources? really a sea of stuff to learn in the asp.net mvc world :)
For example i have a static class with this current function. how do i get the same result using asp.net mvc?
public static int getCountry(Page page)
{
return getCountryFromIP(getIPAddress(page));
}
public static string getIPAddress(Page page)
{
string szRemoteAddr = page.Request.ServerVariables["REMOTE_ADDR"];
string szXForwardedFor = page.Request.ServerVariables["X_FORWARDED_FOR"];
string szIP = "";
if (szXForwardedFor == null)
{
szIP = szRemoteAddr;
}
else
{
szIP = szXForwardedFor;
if (szIP.IndexOf(",") > 0)
{
string [] arIPs = szIP.Split(',');
foreach (string item in arIPs)
{
if (!isPrivateIP(item))
{
return item;
}
}
}
}
return szIP;
}
And how do i call this function from the controller page? thanks.