Open Closed

Maui blazor app Exception error (Cannot invoke JavaScript outside of a WebView context.) #4326


User avatar
0
yasin.hallak.89@gmail.com created
  • ABP Framework version: v7.0.0
  • UI type:Maui Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:

An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Volo.Abp.AspNetCore.Components.MauiBlazor.AbpAspNetCoreComponentsMauiBlazorModule, Volo.Abp.AspNetCore.Components.MauiBlazor, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null: Cannot invoke JavaScript outside of a WebView context.

  • Steps to reproduce the issue:"

Hi support.

I have created project with Ui MauiBlazor from abp suite.

First : I run HttpApi.Host project.

Second: I run MauiBlazor project as andriod emulator and give me this error as above.

Can you give me some solution please

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

12 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    I'd like to check it remotely, can we have a meeting? shiwei.liang@volosoft.com

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    yasin.hallak.89@gmail.com created

    Hi,

    I'd like to check it remotely, can we have a meeting? shiwei.liang@volosoft.com

    Yes we can I sent you invitation on google meet

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    It's working for me

    Will it work if you run an MAUI-Blazor app without ABP?

    It may be related to your local environment, you can try it on a new computer.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    yasin.hallak.89@gmail.com created

    It's strange !!! . I have created new project without ABP It works well.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Could you try to run it in an emulator? As you know, I can't operate your physical device in the meeting, it's hard to find the problem

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    yasin.hallak.89@gmail.com created

    Could you try to run it in an emulator? As you know, I can't operate your physical device in the meeting, it's hard to find the problem

    Now it's work for me , I have Updated Operating System and reinstall Visual Studio

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    yasin.hallak.89@gmail.com created

    Can I login with mobile without redirect to web page ?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    Yes, you can.

    We use code flow by default, but if you want, you can use the password flow

    You can check this to know how to get access token with password flow:https://github.com/abpframework/abp/blob/dev/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs#L61-L69

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    yasin.hallak.89@gmail.com created

    Hi,

    Yes, you can.

    We use code flow by default, but if you want, you can use the password flow

    You can check this to know how to get access token with password flow:https://github.com/abpframework/abp/blob/dev/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs#L61-L69

    Thanx.

    Just we need to change type from code-flow to the password-flow in configuration and we can login without redirect to web page ?.

    Or we need to do some other changes in code ?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    Just we need to change type from code-flow to the password-flow in configuration and we can login without redirect to web page ?.

    No, you need to create your own login page.

    And update ExternalAuthService to use password flow instead of oidcClient

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    yasin.hallak.89@gmail.com created

    Hi,

    Just we need to change type from code-flow to the password-flow in configuration and we can login without redirect to web page ?.

    No, you need to create your own login page.

    And update ExternalAuthService to use password flow instead of oidcClient

    Hi,

    I didn't find any where within OicdClinet to set grantType password flow

    Could you write some hints or steps to change to password flow Please

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    I didn't find any where within OicdClinet to set grantType password flow

    It's not easy, you need a lot of work to do.

    • Create a login page
    • Remove all OidcClient and MauiAuthenticationBrowser used
    • Update ExternalAuthService, for example:
    public async Task<LoginResult> LoginAsync(string userNameOrEmailAddress, string password)
    {
        var client = _httpClientFactory.CreateClient();
        var discoveryDocument = await client.GetDiscoveryDocumentAsync(configuration["OAuthConfig:Authority"]);
    
        var passwordTokenRequest = new PasswordTokenRequest
        {
            Address = discoveryDocument.TokenEndpoint,
            ClientId = configuration["OAuthConfig:ClientId"],
            UserName = userNameOrEmailAddress,
            Password = password,
            Scope = configuration["OAuthConfig:Scope"]
        };
    
        var tokenResponse = await client.RequestPasswordTokenAsync(passwordTokenRequest);
        await _myProjectNameApplicationSettingService.SetAccessTokenAsync(tokenResponse.AccessToken);
        _currentUser = new ClaimsPrincipal(new ClaimsIdentity(new JwtSecurityTokenHandler().ReadJwtToken(tokenResponse.AccessToken).Claims, AuthenticationType));
        UserChanged?.Invoke(_currentUser);
    
        return LoginResult.Success();
    }
    
    public async Task SignOutAsync()
    {
        await _myProjectNameApplicationSettingService.SetAccessTokenAsync(null);
        
        _currentUser = new ClaimsPrincipal(new ClaimsIdentity());
        UserChanged?.Invoke(_currentUser);
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.