jsakamoto / Toolbelt.Blazor.I18nText

The class library that provides the ability to localize texts on your Blazor app!
Mozilla Public License 2.0
246 stars 23 forks source link

Can load translate text if we are not login #29

Closed eanpr closed 4 years ago

eanpr commented 4 years ago

Hi, I use this package in blazor web assembly. If I am not login my application render error. but after after I login it working perfect.

Can you help me how to fix this? Thank

jsakamoto commented 4 years ago

Sorry, I can't help you due to I could not understand what happens in your app.

Anyway, depending on your post, it seems a general problem on the Blazor WebAssembly app, not an issue of this package.

I recommend that you should ask to "stakoverflow" (https://stackoverflow.com/questions/tagged/blazor ) with disclosing your source code.

P.S. By the way, this package will work fine regardless of whether you are logged in or not.

See also the Blazor WebAssembly app below.

(On this app, you can change the language from the footer of this app before you logged in.)

Gambero81 commented 4 years ago

i have the same issue, i use asp.net core authentication and if you are not logged AccessTokenNotAvailableException is raised when call GetTextTableAsync(this)

Gambero81 commented 4 years ago

@jsakamoto can we have support on this issue? with this problem the library is not usable with default asp.net core authentication identity server and jwt.

Thanks

jsakamoto commented 4 years ago

@Gambero81

Could you help me by attaching the zip packaged project file which can reproduce your problem?

Gambero81 commented 4 years ago

I have created a new Blazor WebAssembly App from Visual Studio template with this settings:

I have installed the i18nText package with nuGet, added service in Main and ConfigureServices methods and edited the Index.razor page as follow:

MyBlazorAppIndexRazor

when i run the application the page load without translation and in devtools console return AccessTokenNotAvailableException after the json get request

MyBlazorAppError

This is the project:

MyBlazorApp.zip

Thank you very much @jsakamoto

jsakamoto commented 4 years ago

@Gambero81 @eanpr Hi, everyone.

As I expect, the problem is not the "i18n text" package itself' s problem.

The most fundamental cause is, the default implementation is configured to try to attach access token all HTTP requests even if the request URL is allowed to anonymous access.

Therefore, I changed the code to attach access token to only HTTP requests to the limited specified URL.

I attach my solution as below.

MyBlazorApp.zip

The zip file includes local git repository, so you can see the change log.

image

I hope this my solution is helpful for you.

P.S. Really appreciate for you, @Gambero81 ! You sent to me the detail of the project to reproduce the problem. This was very very helpful for me to work on this problem, and save my time. Thanks!

jsakamoto commented 4 years ago

@Gambero81 @eanpr Hi, everyone.

Today, I published v.9.1 package.

This version improved to works fine out of the box even on an access token-based authorization enabled site.

Thanks for your contribution! 👍