Hello,
I have developed my app using this template and it works fine running locally. But, when I run it on Azure I get this intermittent error:
blazor.webassembly.js:1 Exception: Microsoft.JSInterop.JSException: Could not find 'getAntiForgeryToken' ('getAntiForgeryToken' was undefined).
and this will be followed by a number of errors in my services (that rely on the token I assume). This error will resolve itself if I refresh the page but it does happen often. Is there a way to resolve this issue? I have Azure .Net set to 7 (as in my local environment) and I have tried turning WebSockets on.
My setup is a little different from how you setup your services. Here is an example:
Client/Services/MyService.cs:
```
private readonly IAntiforgeryHttpClientFactory _httpClientFactory;
public AsaDomainService(IAntiforgeryHttpClientFactory httpClientFactory)
{
_httpClientFactory = httpClientFactory;
}
public async Task<ServiceResponse<List<ObjectDTO>>> GetAllObjects()
{
var client = await _httpClientFactory.CreateClientAsync("default");
var result = await client.GetFromJsonAsync<ServiceResponse<List<ObjectDTO>>>("api/MyObjects/get-all-objects");
return result;
}
**Server/Contorller/MyController.cs**
private readonly IObjService _ObjService;
public MyController(IObjService objService)
{
_objService = objService;
}
[HttpGet("get-all-objects")]
public async Task<ActionResult<ServiceResponse<List>>> GetAllObjects()
{
return Ok(await this._objService.GetAllObjects(true));
}
**Server/Services/MyServerService.cs**
//this service does the DB calls and returns the object
Thank you for the assistance!
Hello,
I have developed my app using this template and it works fine running locally. But, when I run it on Azure I get this intermittent error:
blazor.webassembly.js:1 Exception: Microsoft.JSInterop.JSException: Could not find 'getAntiForgeryToken' ('getAntiForgeryToken' was undefined).and this will be followed by a number of errors in my services (that rely on the token I assume). This error will resolve itself if I refresh the page but it does happen often. Is there a way to resolve this issue? I have Azure .Net set to 7 (as in my local environment) and I have tried turning WebSockets on.
My setup is a little different from how you setup your services. Here is an example:
Client/Services/MyService.cs:
private readonly IObjService _ObjService;
public MyController(IObjService objService)
{
_objService = objService;
}
[HttpGet("get-all-objects")]
public async Task<ActionResult<ServiceResponse<List>>> GetAllObjects()
{
return Ok(await this._objService.GetAllObjects(true));
}