locked
XHR and localhost

    Question

  • Hi,

    In my app, users has the ability to specify the server they want to use (they have to install their own server)

    Most of them uses a remote server, but some installs the server on the same machine

    I use WinJS.xhr to connect and get the datas I want. When the server is remote, there is no problem at all. However, when they enter localhost, 127.0.0.1 or even the LAN IP (on 192.168.1.x), it says it can't connect. Console gives an error: 00002efd

    I have found some posts on the forum, but none gave me a fix, as I need it to work on any computer. I can't imagine requiring the users to download a proxy or modify the registry

    Having such limitations is just stupid, just like the codecs thing, if you can't even trust the developpers, they you have trust problems, it's not because we access a local port that it's to harm

    Any way to connect to localhost using xhr ?

    Mika.

    Friday, October 19, 2012 7:24 PM

Answers

  • Hi Mika,

    As the above thread mentioned, disabling loopback check is just a workaround for testing purpose at development time. Accessing localhost hosted webservice (if not hosted in the same process) is still blocked for production environmen.

    http://msdn.microsoft.com/en-us/library/windows/apps/Hh780593.aspx


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Putting communities in your palms. Launch the browser on your phone now, type aka.ms/msforums and get connected!

    • Marked as answer by Song Tian Saturday, October 27, 2012 6:37 AM
    Wednesday, October 24, 2012 3:55 AM
    Moderator
  • Hi Mika,

    The answer is no, you cannot connect to localhost.  Thanks for your feedback on this issue!

    I suggest you provide try catch block and test for this error and indicate to your customer that you cannot connect to localhost because of the design of the Windows Store app security model.

    Jeff


    Jeff Sanders (MSFT)

    Wednesday, October 24, 2012 11:54 AM
    Moderator

All replies

  • windows store apps cant connect to localhost.. just in development envoriment it should work. then visual studio unlocks it.

    Friday, October 19, 2012 7:58 PM
  • how about using the FQDN - domain name of the computer in the url? In theory this should work...

    Can Bilgin
    Blog CompuSight

    Saturday, October 20, 2012 7:32 AM
  • Hi Mika56,

    the xhr's localhost access is blocked for security protection consideration. You can find the following thread which  discussed on the same question:

    #Access localhost using xhr
    http://social.msdn.microsoft.com/Forums/en-US/winappswithhtml5/thread/f980fedb-eb7e-4ff9-a3fc-a5ed8e1419ec


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Putting communities in your palms. Launch the browser on your phone now, type aka.ms/msforums and get connected!

    Tuesday, October 23, 2012 8:09 AM
    Moderator
  • Sorry I forgot to answer...

    Disabling Loopback check is a fix, but still, I have to ask my own users to enter a command in order to access their own computer, where's the logic in here?

    Mika.

    Tuesday, October 23, 2012 8:44 AM
  • Hi Mika,

    As the above thread mentioned, disabling loopback check is just a workaround for testing purpose at development time. Accessing localhost hosted webservice (if not hosted in the same process) is still blocked for production environmen.

    http://msdn.microsoft.com/en-us/library/windows/apps/Hh780593.aspx


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Putting communities in your palms. Launch the browser on your phone now, type aka.ms/msforums and get connected!

    • Marked as answer by Song Tian Saturday, October 27, 2012 6:37 AM
    Wednesday, October 24, 2012 3:55 AM
    Moderator
  • Hi Mika,

    The answer is no, you cannot connect to localhost.  Thanks for your feedback on this issue!

    I suggest you provide try catch block and test for this error and indicate to your customer that you cannot connect to localhost because of the design of the Windows Store app security model.

    Jeff


    Jeff Sanders (MSFT)

    Wednesday, October 24, 2012 11:54 AM
    Moderator
  • Hi,

    Thank for you answer

    However, this is not an acceptable solution, this "security" is not a security, since Windows 3.11 for Workgroups, any app was able to connect to any port on any machine, including localhost. Windows 8 is supposed to be an evolution, and since I started my "Modern UI" app, I keep seeing things I am no longer able to do

    Connecting to localhost is not my choose, it's my customers choice, and I have, as you should have, to respect that

    Mika.

    Wednesday, October 24, 2012 12:00 PM
  • Again, thanks for the feedback.


    Jeff Sanders (MSFT)

    Wednesday, October 24, 2012 1:15 PM
    Moderator