What would be the main difference between the two?
The Stream
is one abstract base class for all streams (more complete definition) that can exist as well you can encode algorithms that require stream without knowing where they come from and go.
MemoryStream
is one concrete class, obviously derived from Stream
as can be observed in the question code, and works with data streams in raw memory.
Are there any advantages to performance gain?
For what? Between one of them? How one is abstract can not even be compared. If it is with others you need to see the implementation of each one, it depends on the hardware where it works.
For web use, which one is the right one?
Between the two will always be the concrete class since the abstract does nothing. If you want to compare with other things it does not make sense to analyze the use for web, web development is something too generic to define something.
Among the existing streams in .NET I do not see another that could be used for web specifically, but in general yes. It is possible to use some other third party or develop your own. The linked documentation above has all .NET classes that inherit from Stream
.
Your case
If what you are doing works and meets all the requirements you want in all situations, that is, if it is right, okay. It seems to me that this case is okay, it is loading a PDF with specific API and throwing it in memory as this API allows. I'm going to kick that it does not need to be a stream in this case, but I do not know if the PDF Viewer API has another way to access it. If the intention is to send directly to another location then it may be that another is more appropriate, but the question we can not know.
The problem usually occurs because people do not read the documentation, do not understand collateral points and do not test all situations that can occur, in general the person tests to work, when the test is sure to not work and find out where to give problem and avoid it.