Skip to content

CORS error when calling IFile.GetContentAsync from Blazor #736

@TimDol64

Description

@TimDol64

Category

  • Bug

Describe the bug

When calling GetContentAsync() on an IFile object from a Blazor project, an error is thrown:
"Access to fetch at 'https://<tenant>.sharepoint.com/sites/DevSite/_vti_bin/client.svc' from origin 'https://localhost: <port>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.'

Note: setting the IFile object and accessing its properties works as expected.

Steps to reproduce

  1. See attached code file
  2. Update the relative path on line 28 to a valid path
  3. Run the app and verify that @file.Name is displayed
  4. Uncomment line 31
  5. Verify that a CORS error is thrown

Expected behavior

I expect the contents of the file to be loaded to a stream.

Environment details (development & target environment)

  • SDK version: 1.5.22-nightly
  • OS: Windows 10 x64
  • SDK used in: Blazor WebAssembly
  • Framework: .NET 6
  • Browser(s): Edge v97.0.1072.69
  • Tooling: Visual Studio 2022
  • Additional details: none

Additional context

Sorry, none.
GetContextAsync.razor.txt

Metadata

Metadata

Assignees

Labels

area: framework ⚙Changes in the SDK core framework codebugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions