locked
How To Get IP Address When Somebody Logins to the Asp.net Web Application RRS feed

  • Question

  • Hi

    There's requirement to obtain the ip address when our users login to the particular application. To elaborate , i have a asp.net web application deployed on Window Server 2008 and we have three business buildings where we would like this application to use from. These three buildings have different network set up and we want to restrict users to access this web application outside of these buildings. Is there object or microsoft api to identify from the user coming from ?

    Thanks



    Bhupinder Singh


    Friday, November 29, 2013 10:49 PM

Answers

  • Hi,

    The forum supports .Net Framework Setup. Your issue isn't related to the forum.

    And Victor have replied you, If his reply have helped you, please mark his reply as answer.

    If it can't help you solve your issue, plesae post your issue to the ASP.NET forum for better support.

    http://forums.asp.net/

    I will move the thread to offic-topic forum.

    Thanks for your understanding.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Just Karl Tuesday, January 14, 2014 9:03 PM
    • Marked as answer by Bhupinder_Singh Tuesday, January 14, 2014 9:33 PM
    Monday, December 2, 2013 6:27 AM

All replies

  • Hi Bhupinder
    You can use this code:

    string ip = Request.ServerVariables["REMOTE_ADDR"];

    if you surf behind a internet proxy, you need to use this code:

        string ipString;
        if (string.IsNullOrEmpty(request.ServerVariables["HTTP_X_FORWARDED_FOR"]))
            ipString = request.ServerVariables["REMOTE_ADDR"];
        else
            ipString = request.ServerVariables["HTTP_X_FORWARDED_FOR"].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();

    Saturday, November 30, 2013 4:02 PM
  • Hi,

    The forum supports .Net Framework Setup. Your issue isn't related to the forum.

    And Victor have replied you, If his reply have helped you, please mark his reply as answer.

    If it can't help you solve your issue, plesae post your issue to the ASP.NET forum for better support.

    http://forums.asp.net/

    I will move the thread to offic-topic forum.

    Thanks for your understanding.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Just Karl Tuesday, January 14, 2014 9:03 PM
    • Marked as answer by Bhupinder_Singh Tuesday, January 14, 2014 9:33 PM
    Monday, December 2, 2013 6:27 AM