I want to create a view using razor template, but I do not want to write a class for model, because in many views i will have many queries which will be returning diferent m
The simplest solution if you are using C# 7.0+ (introduced in Visual Studio 2017+) is to use a tuple rather than an anonymous type.
Razor View: "_MyTupledView.cshtml"
@model (int Id, string Message)
Id: @Model.Id
Id: @Model.Message
Then when you bind this view, you just send a tuple:
var id = 123;
var message = "Tuples are great!";
return View("_MyTupledView", (id, message))