The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
Deploy UWP application connection error RRS feed

  • Question

  • Hi everybody!

    There are UWP app + WebApp (hosted in IIS on localhost).

    UWP connect with HttpClient to http://localhost.

    On developer PC - work good.

    1. Copy and configure WebApp app in new AzureVM - work good (from webbrowser)

    2. Create package and deploy with Add-AppDevPackage.ps1 - app deployed and runned

    3. Run connect with HttpClient to localhost - crash

    System.AggregateException: One or more errors occurred. (An error occurred while sending the request.) ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Runtime.InteropServices.COMException: The text associated with this error code could not be found.

    A connection with the server could not be established

       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Net.Http.HttpHandlerToFilter.<SendAsync>d__1.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Net.Http.HttpClientHandler.<SendAsync>d__1.MoveNext()
       --- End of inner exception stack trace ---
       at System.Net.Http.HttpClientHandler.<SendAsync>d__1.MoveNext()
       --- End of inner exception stack trace ---
       at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
       at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
       at System.Threading.Tasks.Task.Wait()
       at OntargIT.MAS.RestApi.ApiCore`1.<Post>d__2.MoveNext()
    ---> (Inner Exception #0) System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Runtime.InteropServices.COMException: The text associated with this error code could not be found.

    Any suggestions? Thanks all of you.

    • Edited by nay lynn Saturday, November 9, 2019 10:11 PM
    Saturday, November 9, 2019 9:56 PM

All replies

  • Hi,

    The reason for this behavior is probably that UWP apps are blocked from loopback connections. You can't access the localhost in your app because the loopback restrictions. 

    The only way to enable or disable the network loopback is using the checknetisolation.exe tool. But please remember only side-load apps could try this way.

    Use the following command to enable loopback :

    c:\>checknetisolation loopbackexempt -a -n=<package family name>

    Use the following command to disable loopback :

    c:\>checknetisolation loopbackexempt -d -n=<package family name>

    There are more details here in the document: Using network loopback in side-loaded Windows Store apps. Please note this document is written for Windows 8 but it also works for Windows 10.

    By the way, We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A (Preview)!

    Best regards,

    Roy


    "Developing Universal Windows apps" forum will be migrating to a new home on Microsoft Q&A (Preview)!
    We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A (Preview)!
    For more information, please refer to the sticky post.


    Monday, November 11, 2019 3:08 AM
    Moderator
  • Hi,

    Have you solved your problem? Does my reply help?

    By the way, We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A (Preview)!

    Best regards,

    Roy


    "Developing Universal Windows apps" forum will be migrating to a new home on Microsoft Q&A (Preview)!
    We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A (Preview)!
    For more information, please refer to the sticky post.

    Tuesday, December 3, 2019 10:19 AM
    Moderator
  • Hi,

    Is my reply helpful to you? If you still have problems, please feel free to contact us.

    By the way, We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A (Preview)!

    Best regards,

    Roy


    "Developing Universal Windows apps" forum will be migrating to a new home on Microsoft Q&A (Preview)!
    We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A (Preview)!
    For more information, please refer to the sticky post.

    Tuesday, December 10, 2019 6:31 AM
    Moderator
  • Hi,

    Is my reply helpful to you? If you still have problems, please feel free to contact us.

    By the way, We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A (Preview)!

    Best regards,

    Roy


    "Developing Universal Windows apps" forum will be migrating to a new home on Microsoft Q&A (Preview)!
    We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A (Preview)!
    For more information, please refer to the sticky post.

    Wednesday, December 11, 2019 8:08 AM
    Moderator