`BinaryFormatter` is an insecure serializer built into the .net framework, that's disabled by default in ASP.NET web apps since .NET 5.0. Microsoft advises against its use and is in the process of removing it. It serializes fields regardless of their visibility into an unspecified binary format. It supports polymorphism and cyclic object graphs.
According to the class's documentation page :
BinaryFormatter is insecure and can't be made secure. For more information, see the BinaryFormatter security guide.
BinaryFormatter serialization methods are obsolete and prohibited in ASP.NET apps
An open source, cross-platform alternative is Protocol Buffers. In .NET Protocol Buffers are supported through the gRPC tooling or libraries like protobuf-net