MVC Views¶
Danger
We do not recommend using MVC views for any purpose. Please contact the Suite Team if you are about to do so.
The MVC Module supports loading MVC pre-compiled views. This is mostly useful for security critical applications, like the Users Identity Service, which has the OAuth2 implementation.
Pre-compiled views¶
When we say pre-compiled views, we mean that, when you build your module
.cshtml files will get compiled into a separated .Views.dll file. This is
normal ASP.NET behavior.
Suite Application Modules¶
For Suite Applications, since they are already a csproj SDK of type
Microsoft.NET.Sdk.Web, the .Views.dll will get auto-generated if you have
view files.
However for the MVC Module to discover your views, you need to explicitly tell
it which assemblies are expected to have a .Views.dll file. For example:
| C# | |
|---|---|
Suite Modules¶
If the module containing the views is not the Root Module, the csproj will be
a Microsoft.NET.Sdk and won't generate views automatically.
If you are creating a new module there's a Template Suite MVC Module that you can use.
However, if you want to add views to an existent module, you need to:
- Change the SDK to be
Microsoft.NET.Sdk.Razor - Set the
AddRazorSupportForMvcto true.
For example:
You'll also need to make the module containing the views, depend on the
EndpointsModule:
| C# | |
|---|---|