- ABP Framework version: v7.4.2
- UI Type: Blazor WASM and Maui Blazor
- Database System: SQL Server
- Tiered (for MVC) or Auth Server Separated (for Angular): no
- Exception message and full stack trace:
- Steps to reproduce the issue:
- Shut down the API or turn off all internet connections on mobile.
- Try to open the app
- App crashes
It looks like if you do not have access to the internet or if the API is down, the application crashes on launch on both the Blazor and Maui Blazor projects. Is this normal? If you do not have access to the api, an exception is thrown when abp services get injected in the program.cs. This is very breaking on mobile and I think the app should be able to support offline mode.
7 Answer(s)
-
0
-
0
I understand that I can show a friendlier error page, but here, I am interested in having the app work despite having no internet connection. Especially on mobile.
The chances of people having no internet access on their mobile is much higher than on a computer. On a Maui Blazor project, the app doesn't even launch. It just crashes.
-
0
Hi,
Ok, I understand that.
I will check if it is possible
-
0
@liangshiwei any update on this?
-
0
Hi,
You can try something like this:
public class ApiNotAvailableHandler : DelegatingHandler, ITransientDependency { protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { // check network or remote server is available //return a cache or fake response var fakeResponse = new HttpResponseMessage(HttpStatusCode.OK); fakeResponse.Content = new StringContent("{}"); return Task.FromResult(fakeResponse); } }
PreConfigure<AbpHttpClientBuilderOptions>(options => { options.ProxyClientBuildActions.Add((_, builder) => { builder.AddHttpMessageHandler<ApiNotAvailableHandler>(); }); });
-
0
Hello @liangshiwei,
Awesome, with that code at least we get the app to launch on mobile. I can handle the rest.
Thank you!
-
0
: )