9

My API doesn't use any database or any authentication. API supports just basic functions. Is there any way to host a .Net Core API on Android?

5
  • I am not sure you understand what you are asking... But in any case. You can turn your android phone to a web server with apache. Just google how. Here is a link as well techrepublic.com/article/… Commented Feb 16, 2020 at 18:21
  • 3
    @panoskarajohn I know there are HTTP server apps for android. What I am asking is self-hosting .Net Core API. Commented Feb 16, 2020 at 18:42
  • 1
    @emert117 Did you get any solution to host an API on android? Commented Oct 28, 2021 at 8:43
  • @sinsedrix take a look at hanselman.com/blog/… Commented Oct 28, 2021 at 15:38
  • 1
    @emert117 nothing about hosting on android on this page Commented Oct 29, 2021 at 7:51

1 Answer 1

1

Assume your Android app is written in .NET MAUI, you just need to inject the initialization of ASP.NET Core in App.xaml.cs,

namespace MauiApp;

public partial class App : Application
{
    public App(WebAppHost webAppHost)
    {
        InitializeComponent();

        MainPage = new AppShell();

        // Start web app server.
        _ = Task.Run(() => webAppHost.StartAsync());
    }
}

The full sample can be found on GitHub.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.