Wednesday 16 January 2013

Get a user's client IP address in ASP.NET?

We have Request.UserHostAddress to get the IP address in ASP.NET, but this is usually the user's ISP's IP address, not exactly the user's machine IP address who for example clicked a link. How can I get the real IP Address?


Often you will want to know the IP address of someone visiting your website. While ASP.NET has several ways to do this one of the best ways we've seen is by using the "HTTP_X_FORWARDED_FOR" of the ServerVariables collection.
Here's why...
Sometimes your visitors are behind either a proxy server or a router and the standardRequest.UserHostAddress() only captures the IP address of the proxy server or router. When this is the case the user's IP address is then stored in the server variable ("HTTP_X_FORWARDED_FOR").
So what we want to do is first check "HTTP_X_FORWARDED_FOR" and if that is empty we then simply return ServerVariables("REMOTE_ADDR").
While this method is not foolproof, it can lead to better results. Below is the ASP.NET code in C#:
using System;
using System.Net;
 
public class IPNetworking
{
  public static string GetIP4Address()
  {
    string IP4Address = String.Empty;
 
    foreach (IPAddress IPA in Dns.GetHostAddresses(Request.ServerVariables["REMOTE_ADDR"].ToString())))
    {
      if (IPA.AddressFamily.ToString() == "InterNetwork")
      {
        IP4Address = IPA.ToString();
        break;
      }
    }
 
    if (IP4Address != String.Empty)
    {
      return IP4Address;
    }
 
    foreach (IPAddress IPA in Dns.GetHostAddresses(Dns.GetHostName()))
    {
      if (IPA.AddressFamily.ToString() == "InterNetwork")
      {
        IP4Address = IPA.ToString();
        break;
      }
    }
 
    return IP4Address;
  }
}

Tuesday 15 January 2013

PTA to Remain Chairman-Less for At Least a Month: Sources


Government of Pakistan is likely not to appoint any new chairman for Pakistan Telecommunication Authority for at least one month, told us highly placed sources, who are directly aware of the development.
Chairmanship of PTA was spared yesterday when Mohammad Farooq Awan was removed by a Lahore High Court as his appointment was declared null and void.
Hearing a petition filed by Khawaja Saad Saleem (of Nayatel), that had challenged the appointment of Mr. Farooq Awan as Chairman PTA, Justice Mansoor Ali Shah of Lahore High Court said that appointment was not in accordance to law.
After removal of Mr. Farooq Awan, our source tell, Mr. Nasrul Karim Ghaznavi, member finance, is likely to get administrative charge for running day to day operations at authority. Government will probably wait for a month and half before appointing any regular chairman at PTA.
This can particularly be true because the service term for both the members (finance and technical) is ending next month, while the extension for Dr. Khawar Siddique Khokhar, member Technical, has been disapproved. He is retiring from PTA on February 24th, 2013 after completing four year term. Similarly, Mr. Nasrul Karim Ghaznavi will complete his service term on February 25th, 2013.
As per sources, government has learned from its mistakes and will not directly appoint any chairman this time. Instead it will appoint a member before making him/her the chairman of the authority. Meaning that, government will have to wait for one month to appoint someone the member of the authority.
It merits mentioning here that current members, who are eligible for becoming the chairman, are not in good books of government. Their differences with Raja Parvez Ashraf, the Prime Minister of Pakistan, grew when both the members denied to sign the IM for 3G. It is said that government considers both the members the sole reason for delay in 3G auction.
On other hands, before his removal, Muhammad Farooq Awan had initiated the process for increasing the members’ count at PTA, which has now matured and is supposed to become a policy soon. It is said that government may soon notify to increase PTA’s member count from three to five. Additional members will include: Member Legal and Member Commercial.
In any case, the government must wait till at least one member slot is vacated, until then Mr. Ghaznvi will remain the acting head of authority.
We will of course keep you posted with any developments on this.

Sony Unveils its Flagship Xperia Z Android Smartphone



Sony Xperia Z 03 Sony Unveils its Flagship Xperia Z Android Smartphone
Sony unveiled its first quad core Android smartphone, the Sony Xperia Z, at CES 2013, for which it is hoping to give tough time to competition smartphones namely Samsung’s S3 and iPhone 5.
After acquiring the Ericsson part of the company in 2011, the Japanese phone manufacturer is finally into the race with top-notch Android smartphones. Extremely sleek and solid built Sony Xperia Z will run on Android 4.1 Jellybean (planned for upgrade to 4.2) with a Snapdragon™ S4 Pro quad-core processor, promising a super-fast performance and unparalleled graphics.
Sony has put a special emphasis on the design. Company said that Xperia Z design is focused on creating balance and symmetry in all directions, with subtly rounded edges and smooth, reflective surfaces on all sides, which are held together by an innovative skeleton frame. Both the front and back are made of glass, with a reflection coating on the top, bottom and sides.
Sony Xperia Z will sport 5 inch full HD screen and 13 megapixel rear camera plus a 2.2 megapixel front facing camera.
Here are complete specs for Sony Xperia Z:
  • OS: Android OS, v4.1.2 (Jelly Bean), planned upgrade to v4.2 (Jelly Bean)
  • Processor:
      • Qualcomm MDM9215M / APQ8064
      • CPU: Quad-core 1.5 GHz Krait
      • GPU:Adreno 320
  • Design:
    • Dimensions: 5.47 x 2.80 x 0.31 in
    • Weight: 146 g
    • IP57 certified – dust and water resistant
    • Water proof up to 1 meter and 30 minutes
  • Display:
    • TFT capacitive touchscreen, 16M colors
    • Size: 1080 x 1920 pixels, 5.0 inches (~441 ppi pixel density)
    • Sony Mobile BRAVIA Engine 2
  • Memory:
    • Card slot: microSD, up to 32 GB
    • Internal: 16 GB, 2 GB RAM
  • Connectivity: GPRS, EDGE, HSDPA, LTE, Wi-Fi 802.11 b/g/n, Wi-Fi Direct, DLNA, Wi-Fi hotspot, Bluetooth v4.0 with A2DP, NFC, USB
  • Camera:
    • Primary: 13.1 MP, 4128×3096 pixels, autofocus, LED flash
    • Secondary: 2.2 MP
  • Battery:
    • Li-Ion 2330 mAh battery
    • Stand-by: Up to 550 h (2G) / Up to 530 h (3G)
    • Talk time: Up to 11 h (2G) / Up to 14 h (3G)
Sony has said that phone will ship during Q1 of 2013 but no pricing information was made available. It is anticipated that phone will hit stores at around USD 650 (or Rs. 65,000) without subsidies.
Sony also announced a lighter version of Xperia Z, the Sony Xperia ZL, which we will be covering in a seperate post.
 Sony Xperia Z Picture Gallery:

Monday 7 January 2013

Control your paswords between comptuers and devices

Most people today are using more than just their computer to log into online services making it much harder to manage and store all your passwords between multiple computers, cell phones, and tablets. The service known as Dashlane helps solve this problem by making it easy to store, change, and share all your online passwords between all types of computers, cell phones, and tablets. In addition to managing your passwords the service can also Autofill out any online form, save online electronic receipts, warn you about password vulnerabilities, send you password alerts, generate strong passwords, and much more.
Dashline uses the strongest encryption there is by encrypting all data using AES-256 and only you know the master password since Dashline does not store the master password on any of their servers and not even on your local computer. The master password is also never sent in transmission so it cannot be intercepted by any man-in-the-middle attack. Since the service is a cloud based service, Dashline syncronize your information between computers and devices using a Device Key, which is not related to the master password.


Bonus Tip: Click Tools and then Prefrences. In the Prefrences window click Security and then click Click to unlock settings. Check the "Automatically log out after inactivity" and specify a time. This will log Dashlane out and prevent anyone who has access to your computer from accessing your accounts.

 

Copyright @ 2013 PakTechClub.