Setting a value from Session Variables with asp.net mvc 5
<p>everyone! I'm new here, and like everyone else, came for getting some help with a little project I'm working on.</p>

<p>My code on C# and Razor works as following: An app's user needs to perform a rating in a recipe previously stored in the DB, with the restriction that can't rate a recipe more than once. </p>

<p>Thing's fine, but need to add that restriction in conjunction with the user that's rating the recipe. I got a DropDown list that lists all users and can do the submit into DB and all, but I want that the user that's logged in submits the form, and no one else or being "selectable", that's how's working for now.</p>

<p>I'm using session variables for getting the user's ID and general info, but I can't get it into work, because the foreign key assosiates to that, and when I try to retrieve it manually, I got only the ID (that's the foreign key in the table), but need to show who's doing the submit and not the ID, even if is requiered in a HiddenFor.</p>

<p>How can I solve this little problem? Any help is truly appreciated :)</p>

<p>The GET and POST methods from recetastblController.cs</p>

<pre><code>    // GET: recetastbl/Rate
    public ActionResult Rate(usuariostbl usuariostbl)
    {
        var puntuaciontbl = db.puntuaciontbl.Include(p =&gt; p.recetastbl).Include(p =&gt; p.usuariostbl);

        ViewBag.usuariostbl = Session["usuarioConectado"];
        ViewBag.usuariostbl_id = ViewBag.usuariostbl.id;
        ViewBag.usuariostbl.username = ViewBag.usuariostbl.username;

        ViewBag.usuariostbl_id = new SelectList(db.usuariostbl, "id", "username");
        ViewBag.recetastbl_id = new SelectList(db.recetastbl, "id", "receta");

        return View();
    }

    // POST: recetastbl/Rate
    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Rate([Bind(Include = "id,valoracion,usuariostbl_id,recetastbl_id")] puntuaciontbl puntuaciontbl)
    {
        if (ModelState.IsValid)
        {
            db.puntuaciontbl.Add(puntuaciontbl);
            db.SaveChanges();

            return RedirectToAction("Index");
        }

        ViewBag.usuariostbl_id = new SelectList(db.usuariostbl, "id", "username", puntuaciontbl.usuariostbl_id);
        ViewBag.recetastbl_id = new SelectList(db.recetastbl, "id", "receta", puntuaciontbl.recetastbl_id);

        return View("Index");
    }
</code></pre>

<p>The full view Rate.cshtml</p>

<pre><code>@model Prueba3Progra4.puntuaciontbl

@{
    ViewBag.Title = "Valorar Receta";
}

&lt;h2&gt;Valorar&lt;/h2&gt;

@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()

&lt;div class="form-horizontal"&gt;
    &lt;h4&gt;Receta&lt;/h4&gt;
    &lt;hr /&gt;
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    &lt;div class="form-group"&gt;
        @Html.LabelFor(model =&gt; model.valoracion, htmlAttributes: new { @class = "control-label col-md-2" })
        &lt;div class="col-md-10"&gt;
            1 Estrella
            @Html.RadioButtonFor(model =&gt; model.valoracion, "1", new { htmlAttributes = new { @class = "form-control" } })
            2 Estrellas
            @Html.RadioButtonFor(model =&gt; model.valoracion, "2", new { htmlAttributes = new { @class = "form-control" } })
            3 Estrellas
            @Html.RadioButtonFor(model =&gt; model.valoracion, "3", new { htmlAttributes = new { @class = "form-control" } })
            4 Estrellas
            @Html.RadioButtonFor(model =&gt; model.valoracion, "4", new { htmlAttributes = new { @class = "form-control" } })
            5 Estrellas
            @Html.RadioButtonFor(model =&gt; model.valoracion, "5", new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model =&gt; model.valoracion, "", new { @class = "text-danger" })
        &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class="form-group"&gt;
        @Html.LabelFor(model =&gt; model.usuariostbl_id, htmlAttributes: new { @class = "control-label col-md-2" })
        &lt;div class="col-md-10"&gt;
            @Html.DropDownList("usuariostbl_id", null, htmlAttributes: new { @class = "form-control" })
            @Html.ValidationMessageFor(model =&gt; model.usuariostbl_id, "", new { @class = "text-danger" })
        &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class="form-group"&gt;
        @Html.LabelFor(model =&gt; model.recetastbl_id, htmlAttributes: new { @class = "control-label col-md-2" })
        &lt;div class="col-md-10"&gt;
            @Html.DropDownList("recetastbl_id", null, htmlAttributes: new { @class = "form-control" })
            @Html.ValidationMessageFor(model =&gt; model.recetastbl_id, "", new { @class = "text-danger" })
        &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class="form-group"&gt;
        &lt;div class="col-md-offset-2 col-md-10"&gt;
            &lt;input type="submit" value="Valorar" class="btn btn-default" /&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
}

&lt;div&gt;
    @Html.ActionLink("Volver a la Lista", "Index")
&lt;/div&gt;

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
</code></pre>