-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Support for MAUI runtimes in ASP.NET Core? #35077
Comments
(Transferring back to aspnetcore repo...) Hi @JustArchi , code that is specific to ASP.NET Core scenarios, such as hosting Kestrel, requires platform support, which as you discovered, it not available on some platforms, such as Android. I think this might really be a question for the ASP.NET folks as to whether there is a desire to support certain features, such as Kestrel, on "arbitrary" platforms, or whether to specifically add support to particular platforms (e.g. android-x86). Hosting a local web server in a cross-platform app is something reasonable (though perhaps not super common), so it's worth considering. For right now I'm not aware of any plan to support this. |
Tagging @danroth27 because I think you mentioned something about this the other day. |
Thanks for your answer @Eilon, I appreciate it.
Yeah I definitely don't see everybody jumping on this idea right away and bundling every Android/iOS/etc app with a local web server, but I also came to conclusion that it's something reasonable enough to at least suggest/evaluate on. I have no idea how much work would be required to bring ASP.NET Core runtime to those new .NET 6.0 platforms, but if it helps in any way then I'd be definitely interested in making use of such functionality, at least for that one use case I have in mind. It could also be a decent alternative if somebody wanted to build an app that looks more like a typical website to you. To give you some idea, I have a CLI app realizing its functionality with bundled Kestrel web server and MVC APIs, which is not really any different from a typical ASP.NET Core website, but it's more of the CLI app and APIs are just an extra. Anyway, I bundle that app with frontend written in html/css/js (static files that Kestrel serves), which results in user navigating to his As an experiment I tried to convert this "idea" into Android app, where the app could create a very simple I'm describing that just to give you some insight into what this whole "feature request" could be useful for, while MAUI is great on its own and building new apps is definitely going to be interesting, there might be more of such CLI apps with some kind of web interface that could easily be converted into Android apps without much hassle if just the ASP.NET Core runtime was available to make use of. It's not like my app requires something more than a web server with static files and MVC APIs anyway. In any case thank you in advance for evaluation of this idea, perhaps it could be something to think of for the future. |
@davidfowl feel free to update the label. This seems to be the closest match. |
@JustArchi to second your "reasonable scenario" statement. We are actually started using local GRPC (client and server) in our current Xamarin app as an IPC technology to communicate between two apps. We have some LOB-concerns which forces us to do a lot (and kinda complex) local IPC between our app and a third party app. And to use one identical API technology on all Platforms targets (Android, iOS and Windows) we've chosen grpc. |
I've got the "same" problem.
The same goes for I created a mauilib with the default structure:
I tried recreating the projects twice from the command line, but it still won't work. Is there a workaround for this? I'd very much like to be able to use DI, but I'm blocked as is. Checking up the nuget repository, I found the references, but for .Mono. Is there something I'm doing incorrectly? |
@eestein .NET MAUI already has support for dependency injection built-in. |
@danroth27 thanks, I appreciate you taking the time to evaluate my question. This is the info for my maui lib. These are my usings:
These are the only nuget packages I've got installed: This is my csproj:
And I still get the error:
I'm not trying to waste anyone's time here, believe me when I tell you I research a lot before asking. The thing is I'm stuck on this one since yesterday. Before trying many things I found online I recreated the projects twice and they still won't work. I tried recreating from VS2022 and also from the command line on my macOS. I still get the error when I reference my mauilib from the maui app. |
Why did you include ASP.NET Core if you're only trying to use dependency injection? |
@davidfowl I didn't... I just created the maui lib using the provided template. And, I also tried removing that framework, I just couldn't find a way to do so. I do need to use HttpClient, though |
@eestein is that the CSPROJ of the project that's failing, |
@Eilon let me take a closer look and I'll get back to you on that. Thanks. I'm also looking for specific packages that could be adding the FW. |
Maybe it's the SampleData project reference? |
A plain |
Thank you, gentlemen! I'm sorry to have wasted your time. But I also think, if possible, a better error message could be provided. If in the message we could see the offending library, that would help a lot! Thank you all, @danroth27 , @Eilon and @davidfowl Please consider my suggestion for the error message. |
Come on guys and gals, GRPC is THE strongly advertised tech from MS for IPC and SOA. In the end, that was the promise MS made, one runtime for all Platforms, not: your lib might only run on one or two Net 6 runtimes (bot not on ios or android or uwp). Today we can still use the "Grpc.Core" Server wich works without asp.net, but this will be deprecated in the near future.
|
I am quite confused why this is still not supported. I already use the Kestrel webservice in my Xamarin app for a while. It seems that I tested it with iOS, Android and UWP applications without any issues. I was hoping that MAUI and .NET 6 would really bring us one .NET. |
Hi folks. I'd like to collect some more details on the specific scenarios for using ASP.NET Core in a mobile app. So far from the feedback in this issue I've identified two scenarios:
Anything else? |
@danroth27 thanks for taking a look into this. Additional to #35077 there is local network GRPC planned.
tl/dr:
It all boils down to one person continuously switching between 3 devices (mobile phone, pc, smartwatch) to do its work. Usually you would do that with a central server/could service holding the state/functionality. |
This absolutely wonderful, thinking about a fully functioning backend web server (restful api, gRPC, signalR, database etc.) working with WebView, this gonna change the way people build mobile apps!!! Really looking forward to this. |
Putting this on the @dotnet/aspnet-blazor-eng radar. This is not really a general |
@dougbu I’m not sure why this is marked a Blazor issue. It has nothing to do with Blazor. When you read my comment from December 7, then I try to explain that it is a fundamental .NET issue, because Kestrel isn’t an ordinary package anymore, but considered a “platform”. It”s not a real MAUI issue, but a fundamental ASP.NET issue. We implemented a Kestrel based webserver (using ancient Kestrel package from the .NET Core 2.2 era) and have an Angular client on top of it. It works great, but not being able to upgrade Kestrel is not a sustainable solution. |
Would using https://github.com/microsoft/vs-streamjsonrpc meet the needs here, for many of the use cases like those described by @softworkz here #35077 (comment)? It seems like a good match and is in fact what I'm using currently for MAUI app to desktop RPC connectivity (over a socket connection). VS / VS Code brokered services also use JSON RPC heavily with this library. It works well. If there's a need for a web server, to serve up web pages, ASP.NET seems like a good match. But when the need is doing bidirectional RPC-style communication between a MAUI app and anything else, using JSON RPC seems like a better tool for the job. |
In the comment you referenced, I wrote:
and futher above:
So I'm afraid, but "strmprcjsn" is far away from any of the use cases I have described.
Which is the actual (and only) subject of this conversation. |
@softworkz Thanks. I think I just misunderstood your use cases. Here's another summary comment #35077 (comment), identifying two main types of use cases:
For the second use case (IPC) doing JSON-RPC, via streamjsonrpc or another library, is arguably a good choice, as is gRPC. No web server required. For the first use case (building a mobile app as a web app), you of course need some kind of web server, ASP.NET being a candidate. Though for that use case, it's not (yet) clear to me why most folks wouldn't want to use MAUI Blazor Hybrid for this, as it's kind of made for that. I expect there are some good reasons, but I haven't read the full thread to understand them yet. |
Maybe because some already have a mature application architecture running on a wide range of platforms and are looking for appropriate middleware which allows them to run their software on MAUI in a webview with little changes (and without redeveloping). Reading through the whole thread reveals, that the ones you quoted are not "the two main use cases". There are many different ones actually, and when you need a webserver, then you need a webserver and not Blazor hybrid and surely not streamrpc or something. There are plenty of ways to do network communication in some form and I think everybody how came here knows that and would have already chosen an alternative way when the requirement wouldn't be specifically about having an http server. |
@softworkz Thanks. I better understand where you're coming from now. |
@BretJohnson Dan Roth asked for scenarios where this feature would be useful. I recommend looking at its replies as a good starting place: #35077 (comment) |
Thanks. I read thru all of the replies (there are so many!). Now I see that while streamjsonrpc (which doesn't require ASP.NET) may be a good choice for greenfield RPC needs, ASP.NET is so darn useful and widely used, including for support of gRPC, that there are lots of reasons to support it (or at least the most used subset of it) being embedded in MAUI apps. |
Bret - somehow I get the impression that you are on an advertising mission, trying to place as many sentences as possible containing strmprcjsn... |
That wasn't really my intention. We've been using it a lot for the Microsoft stuff I work on, including mobile, for IPC, and I rather like it, but folks should use whatever works best for them. If gRPC is a better choice, use it (though I guess it currently has the ASP.NET dependency). Or use something else. I'm on a MAUI tooling team at Microsoft btw - not MAUI itself, but kind of MAUI adjacent. Mostly I wanted to understand well customer needs here, for both IPC and non-IPC scenarios, to help us meet them. And I think I have a pretty good sense of that now. |
Hey @JamesNK and @danroth27, any updates on a roadmap/plans for this? |
Nothing will happen in .NET 9. Other work took priority. We'll consider it for .NET 10. |
Thanks for the Heads-up! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
Stop adding +1 comments. If you're interested in this feature then you can add a thumbs up reaction to the original issue. They're considered when gauging interest in a feature. |
This comment has been minimized.
This comment has been minimized.
There is no stale bot here. Don't spam peoples notifications. |
If you hide my post and reply to it without quoting, your response appears a bit out of place... Anyway, it was rather meant as a joke than condoning "+1" posts. But I think that when people would lay out their uses cases instead and explain why they need it for those, it would provide value to this thread and have more weight than a thumps-up. |
Sure. Because it's almost 2025, and HTTP 0.9 was released in 1991, along with the first HTTP 0.9 server, and .NET is not capable of letting me run its official HTTP 0.9 server on mobile platforms. I hope this explains the use case. |
The use case for the company I'm currently working on: |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
As update to #35077 (comment): With the deadline of https://groups.google.com/g/grpc-io/c/iEalUhV4VrU already passed again (promised to be supported until "at least October 2024") it's a gamble for our company to still have to rely on But it's still annoying as it makes us having to stick on a nearly 2 year old version also for Windows as we have to stick with it for cross-targeting reasons. |
Sadly everything related to maui is a gamble, and has underwhelming support by MSFT.
|
Hey,
I apologize in advance if this is not the correct place to ask this, but I didn't find any better one. Feel free to move this issue if appropriate.
For testing purposes, in MAUI
net6.0-android
project I've tried to reference other project of mine targettingnet6.0
which is a library. I didn't have any issues doing so, but during compilation I've stumbled upon following error:If I understand this right, I can reference standard
net6.0
projects becauseMicrosoft.NETCore.App.Runtime.Mono.android-x86
exists and is usable, at least I successfully did that with examplenet6.0
library. However, I'd like to reference a library that has actual ASP.NET Core elements (Kestrel web server, API with MVC etc), which according to the error is impossible because it can't find a requiredandroid-x86
runtime, which seems to be correct as of today.Now I apologize if I'm trying to do some extreme stupidity, or I don't understand something, but I wanted to verify whether it'd be possible to "convert" existing CLI project of mine which uses Kestrel and API controllers into an Android MAUI app that could start the "backend" part on the target machine, with some nice frontend utilizing those API endpoints over HTTP. I'm testing this in .NET 6.0 preview 6 if it matters.
Is this possible/planned? Or perhaps I'm doing something horribly wrong?
In any case, thank you in advance for answering, I appreciate it.
The text was updated successfully, but these errors were encountered: