C# – is there a way that I can pass just an integer to the view without creating a model in mvc

asp.net-mvc, c++

I have a controller which calls a view. Is there a way I can pass just an integer to my view an be able to use that integer in my view with razor code?

Here is my method in my controller:

public ActionResult Details(int linkableId){    return View(linkableId);}

After returning my view, can I access just this int using razor code like this or something:


Best Solution

In your View, at the very top:

@model Int32

Or you can use a ViewBag.

ViewBag.LinkableId = intval;