Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UsesCleartextTraffic setting information missing #2252

Open
TPJ11 opened this issue May 10, 2024 · 0 comments
Open

UsesCleartextTraffic setting information missing #2252

TPJ11 opened this issue May 10, 2024 · 0 comments
Assignees
Labels
doc-enhancement Improve the current content [org] dotnet-maui/subsvc dotnet-mobile/svc Pri2 📌 seQUESTered Identifies that an issue has been imported into Quest.

Comments

@TPJ11
Copy link

TPJ11 commented May 10, 2024

Type of issue

Missing information

Description

To configure android to accept HTTP traffic from your localhost (such as running an API from VS) you need to set the setting UsesCleartextTraffic to true the documentation does talk about network security configuration but there is a much simpler solution, add the following code at the top of the android MainApplication.cs class found under Platforms -> Android then you can call HTTP endpoints on 10.0.2.2.

#if DEBUG
[Application(UsesCleartextTraffic = true)]
#else
[Application]
#endif

Therefore unless the user has changed other settings the full class will look like

#if DEBUG
[Application(UsesCleartextTraffic = true)]
#else
[Application]
#endif
public class MainApplication : MauiApplication
{
    public MainApplication(IntPtr handle, JniHandleOwnership ownership)
        : base(handle, ownership)
    {
    }

    protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}

Page URL

https://learn.microsoft.com/en-us/dotnet/maui/data-cloud/local-web-services?view=net-maui-8.0

Content source URL

https://github.com/dotnet/docs-maui/blob/main/docs/data-cloud/local-web-services.md

Document Version Independent Id

663379bf-421a-57f1-39b7-e92f830de0ed

Article author

@davidbritch

Metadata

  • ID: 663379bf-421a-57f1-39b7-e92f830de0ed
  • Service: dotnet-mobile
  • Sub-service: dotnet-maui

Associated WorkItem - 259815

@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label May 10, 2024
@davidbritch davidbritch added the doc-enhancement Improve the current content [org] label May 30, 2024
@dotnet-bot dotnet-bot removed the ⌚ Not Triaged Not triaged label May 30, 2024
@davidbritch davidbritch self-assigned this May 30, 2024
@davidbritch davidbritch added the 🗺️ reQUEST Triggers an issue to be imported into Quest. label May 31, 2024
@sequestor sequestor bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-enhancement Improve the current content [org] dotnet-maui/subsvc dotnet-mobile/svc Pri2 📌 seQUESTered Identifies that an issue has been imported into Quest.
Projects
Status: 🔖 Ready
Development

No branches or pull requests

3 participants