0

I have a Blazor Server app hosted on an Azure App Service, which communicates to an on-premises server connected through a VNET on Azure.

I have custom authentication in place where a user will use their login credentials which is validated in the on-premises server which returns a token.


Now my issue is that it seems like there aren't individual instances of the app. I've come to this conclusion because of the following scenario I've encountered:

I have a ZXing barcode scanner which displays a decoded barcode in the following manner:

<input type='text' value='@Barcode' disabled="disabled" />

The value is displayed in the textbox once a barcode is found.

Here is my issue:

  1. Open the app using live URL on my mobile phone and on my PC
  2. I scan the code on my phone
  3. The PC's textbox is updated with the code I just scanned on my phone?

Is there a specific configuration I'm missing or am I misunderstanding how Blazor works?

Brydon
  • 123
  • 11
  • Can you share a little more code? Where does @Barcode come from? Depending on how you set things up, some things are shared between sessions (for example by registering a service with AddSingleton()). – StefanFFM Mar 24 '22 at 15:18
  • Repeat the same trick once more, and then type your app's url in a new tab or a different browser. What do you see ? You're supposed to see a new instance of your app, even if you open it in a new tab. Authenticate as another user – enet Mar 24 '22 at 15:18
  • So what your saying is that two separate sessions display the data input in one of the sessions. This can only happen if the data is either stored in a permanent data store, a static class or in a singleton service, and there's an event driven mechanisms to update values in components. – MrC aka Shaun Curtis Mar 24 '22 at 16:42
  • I finally found the cause. It turns out that the [ZXing Blazor barcode scanner](https://www.nuget.org/packages/BlazorBarcodeScanner.ZXing.JS/) was causing this issue. I manually integrated the [JS library](https://github.com/zxing-js/library) and all is working as intended. – Brydon Mar 25 '22 at 12:54

1 Answers1

-1

The cause was the BlazorBarcodeScanner.ZXing.JS, Blazor barcode scanner .

I manually implemented the JS library and my problem disappeared.

E_net4
  • 27,810
  • 13
  • 101
  • 139
Brydon
  • 123
  • 11