How do I find out the type of a View's Model within the View itself?
I tried doing calling GetType
:
@model MyModel
<div>@Model.GetType()</div>
which works unless the Model
is null, in which case I get a NullReferenceException
.
Unfortunately it's also not possible to do
@model MyModel
<div>@typeof(TModel)</div>
as TModel
is not available in the context of the Razor view.