is there a way that I can pass just an integer to my view without creating a model in mvc

In your View, at the very top:

@model Int32

Or you can use a ViewBag.

ViewBag.LinkableId = intval;

Use ViewBag.

public ActionResult Details(int linkableId)
{
    ViewBag.LinkableId = linkableId;
    return View();
}

and then in your view:

@ViewBag.LinkableId 

This question may also help: How ViewBag in ASP.NET MVC works


In your View, at the very top:

@model Int32

then use this in your view, should work no problem.For example:

<h1>@Model</h1>

Something else that I want to add is is your controller you should say something like this :

return View(AnIntVariable);

Tags:

C#

Asp.Net Mvc