Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TJsonBaseObject.ParseFromFile fails on IIS #74

Open
fastbike opened this issue Apr 28, 2023 · 0 comments
Open

TJsonBaseObject.ParseFromFile fails on IIS #74

fastbike opened this issue Apr 28, 2023 · 0 comments

Comments

@fastbike
Copy link

This is a very strange bug - it only manifests itself under our ISAPI application running on IIS (Windows Server) but not on IIS (Windows 10 professional)

Anyway, making a call to TJsonBaseObject.ParseFromFile returns nil in the error case.
Changing the implementation code as below fixes the problem and the text is parsed correctly into a JSON object.

class function TJsonBaseObject.ParseFromFile(const FileName: string; Utf8WithoutBOM: Boolean{$IFDEF SUPPORT_PROGRESS}; AProgress: PJsonReaderProgressRec{$ENDIF}): TJsonBaseObject;
var
  Stream: TFileStream;
begin
  Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
  try
    // add this line
    Stream.Seek(0, soBeginning);
    Result := ParseFromStream(Stream, nil, Utf8WithoutBOM{$IFDEF SUPPORT_PROGRESS}, AProgress{$ENDIF});
  finally
    Stream.Free;
  end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant