Is there an easy way to tell from within a razor view, whether or not it was rendered as a partial?
Nope, there's no way, other than passing this information as a model value (or ViewData). By the way when you give it a second thought, that would make your code even better, because the partial won't depend on the fact whether it was rendered as partial using the RenderPartial helper or in some other manner. It is self dependent (on its view model only) -> the way all views should be.
Note: this is possible with child actions which will populate the ParentActionViewContext
property.