Ive been successful in setting up a blazor feature template example without authentication.
When i enable identity platofrm, i have progressed to have a working active directory login, so authentication is working.
The file manager fails with the following:
blazor.server.js:21 [2021-12-16T11:24:26.290Z] Error: System.Text.Json.JsonException: '<' is an invalid start of a value. Path: $ | LineNumber: 2 | BytePositionInLine: 0.
---> System.Text.Json.JsonReaderException: '<' is an invalid start of a value. LineNumber: 2 | BytePositionInLine: 0.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
at System.Text.Json.Utf8JsonReader.Read()
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonConverter jsonConverter, Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadCore[TValue](Utf8JsonReader& reader, Type returnType, JsonSerializerOptions options)
at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, Type returnType, JsonSerializerOptions options)
at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
at Syncfusion.Blazor.FileManager.SfFileManager`1.GetData[T](String action, T[] data, T targetData, String path, FileManagerAjaxSettings ajaxSettings, Boolean showHiddenItems, String name, String newName, String[] names, Boolean caseSensitive, String searchString, String targetPath, String[] renameFiles)
at Syncfusion.Blazor.FileManager.SfFileManager`1.Read[T](T[] data, T targetData, String path, FileManagerAjaxSettings ajaxSettings, Boolean showHiddenItems)
at Syncfusion.Blazor.FileManager.SfFileManager`1.OnAfterRenderAsync(Boolean firstRender)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
I assume this is because of some invalid html being returned, but i cant see how to read the inner contents of the underlying error. Any suggestions on what must be changed to get the filemager working?
Thanks, I have followed as requested.
I also note that I have extracted the response, and it is the login request form from login.microsoft.com, so it appears token is not being passed to the http client, and the subsequence filemanager controller api call.
I have checked the HTTPClient service prior to syncfusion service.
I have tried injecting the HTTP client with the headers as per suggestion on various pages, but still this kicks to the login page.
I also encounter a similar issue with a datagrid/datamanager webapiadaptor page where using EF.
UPDATE:
I discovered a nuget version mismatch which was leading to my above scenario.
After upgrading, i now face the issue as discribed in the github article. Ultimately, this is creating very similar symptoms, but i do progress a little further.
Thanks for the follow up.
To clarify, i have
- successfully logged in using Microsoft.Identity.Web
- can successfully pull downstream data using graph api
When calling OnInitialised
var token = await TokenAquisition.GetAccessTokenForUserAsync(new string[] { "User.Read" });
token is set
then call
_httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
a token is set
for testing i used this httpClient to make a GetAsync call to my controller at this point and still requests login, so its not a SF issue
if I manually type the Controller address in new tab, it adheres to loggin session, and does not request login
this is the exact method i use for Microsoft Graph API calls, which function perfectly.
My instinct says my startup has something wrong, but feel ive exhaused my search abilities here. I can attach if you would like.
Hello guys, exact same use case and issue for me, as Daniel described:
"Ive been successful in setting up a blazor feature template example without authentication.
When i enable identity platofrm, i have progressed to have a working active directory login, so authentication is working.
The file manager fails with the following:
blazor.server.js:21 [2021-12-16T11:24:26.290Z] Error: System.Text.Json.JsonException: '<' is an invalid start of a value. Path: $ | LineNumber: 2 | BytePositionInLine: 0. ---> System.Text.Json.JsonReaderException: '<' is an invalid start of a value. LineNumber: 2 | BytePositionInLine: 0. at"...
Syncfusion gents - considering the age and the status of the bug (still in Backlog, and still in investigate) is there a workaround, or anything else you could suggest?
Daniel - if you do read this - did you find an acceptable solution to this while maintaining the identity framework authorization?
Thanks in advance, one of those roadblocks >.<
Dieter
Hey all, while not ideal, here is an immediate workaround. I allowed anonymous access on the controller with the [AllowAnonymous] modifier in the controller. This selective security mod is acceptable, as this is an intranet corporate application. Hope this helps someone else.
Here's the snippet. I renamed the SampleDataController.cs which is part of the FileManager setup documentation to FileManagerController.cs. Modify whichever file is appropriate:
----------
namespace filemanager.Server.Controllers {
[Route("api/[controller]")]
[AllowAnonymous]
public class FileManagerDataController : Controller {
public PhysicalFileProvider operation;
public string basePath;
----------
Hi Dieter,
We were that you have find a workaround way to resolve the issue. However, the reported issue is caused by sample level Windows authentication. As explained earlier, we have used HttpClient for web API calls in FileManager to perform all file operations. Even the basic HttpClient call has the same issue while including the authentication code. We have already raised a general query on this issue.
As of now, you can either comment out the authentication related codes in your Startup.cs file, else follow the steps mentioned in the below blog to enable Authentication in Blazor Server side application to avoid the issue.
https://www.syncfusion.com/blogs/post/easy-steps-create-a-blazor-server-app-with-authentication.aspx
Please check whether the shared details helpful for you and get back to us if you need any further assistance.
Regards,
Indhumathy L
Hi
Is there any news on a proper fix for this issue yet?
I see in the github issue tracker that it was suggested that the calls to the azure blob sdk be implemented inside a service instead of through http calls. This makes a lot of sense and would be more performant.
Are you planning on implementing such a solution?
Thanks
Dave
Hi Dave,
We have considered providing support to customize the HttpHandler of the Blazor File Manager component. By using this support, you can modify HttpClient using the HttpHandler to achieve Windows authentication for the Blazor File Manager. This feature will be included in any of our upcoming releases. Generally, we will plan any feature implementation based on customer request count, feature rank, and wish list plan. You can track the feature status through the below link,
Regards,
Indhumathy L
Thanks for the response.
Voted 8)