UserAgent and UserHostAddress from LS HTML Client RRS feed

  • Question

  • Hello,

    is there a way to get the UserAgent and UserHostAddress from an LS HTML Screen?


    Wednesday, October 30, 2013 1:59 PM


  • Hi robert,

    LightSwitch doesn't supply this information directly via our data service API. However, because the service implementation is running under ASP.NET, there are ways to reach out and get this from the .NET Framework. You can use the HttpContext to get the UserHostAddress.

    You will do the following steps for the intention:

    • In the solution explorer, switch the project view to "File View" intead of "Logical View"
    • Go to the project called "Server"
    • Right-click on the project node and select "Add Reference..."
    • Add a reference to System.Web.dll
    • In the solution explorerer, go back to "Logical View"
    • Expand the "Data Sources" node and select a data service
    • Right-click on the data service and select "View Code". This is where you write your server-specific business logic.

    You can get more details from the similar question below:

    Does LS provide the developer with the user's IP address?


    In addition, there is a sample for your reference:

    LightSwitch lsQuickCode: Fast Login For Mobile Applications


    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 Xpert360 Thursday, October 31, 2013 10:52 AM
    • Marked as answer by Yunjie Pei - MSFT Wednesday, November 6, 2013 10:54 AM
    Thursday, October 31, 2013 9:35 AM