The first question is - is it possible to avoid using controller for server-side blazor application? You did it for FileUpload, but there is not still shown the way to get file and directory data without controller for File Navigator.
I have the next error of Navigator first load:
I have checked the data sent from controller, there is not any <. What is the reason of error could be?
Hi Indhumathy,
On my application an access to page with file navigator is not allowed to users which are not authorized and which role is below administrator.
Is there any other reason to get this error?
In my first message I have added response from controller, and there is not any error here. What should I check more?
If you will need to make the sample, please, use NET6 framework, otherwise I cannot run it.
When received your answer I have attached JWT bearer security to controller and token to request query strings. Result is the same error.
Finally I have understood that the reason of wrong answer was xml-data returned by File Controller. Preference of XML was set on application level.
I have added
[Produces("text/plain")] to the File Controller and everything started to work.
For all which is interesting about authorization of files.
I use jwt bearer to control which files could be shown based on user roles.
File Controller statrs with:
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
[Route("[controller]")]
[EnableCors("AllowAllOrigins")]
[Produces("text/plain")]
public class FileController : ControllerBase
It makes possible to get User.Identity.Name and filter file list based on user role.
To embed jwt-bearer to File Navigator request:
<FileManagerAjaxSettings Url="@("/File/FileOperations".AddQueryParameter("access_token", Token))"
DownloadUrl="@("/File/Download".AddQueryParameter("access_token", Token))"
GetImageUrl="@("/File/GetImage".AddQueryParameter("access_token", Token))"
UploadUrl="@("/File/Upload".AddQueryParameter("access_token", Token))" />