I am starting on ASP.net and I can not resolve the next problem.
System.NullReferenceException: La référence d'objet n'est pas définie à une instance d'un objet.
I forwards a User Id from User controller to this Action, who belongs to Email Controler. Then I want to give this Id to a new parameter.
public ActionResult Create(Guid? id)
{
ViewBag.Key_Destinataire = id;
return View();
}
Le code de ma page HTML : @model ProjetWeb.Models.Email
////
@Html.LabelFor(model => model.Objet, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Objet, new { htmlAttributes = new { @class = "form-control" } })
///
<div class="form-group">
@Html.LabelFor(model => model.Key_Destinataire, "Key_Destinataire", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Model.Key_Destinataire.Value=ViewBag.Key_Destinataire;
@Html.ValidationMessageFor(model => model.Key_Destinataire, "", new { @class = "text-danger" })
</div>
</div>
English Translation;
Hello,
I start on ASP.net and I can not resolve the error below:
System.NullReferenceException : Object reference not set to an instance of an object.
my code below: I transmits the ID of a user of controller User controller in this action the Email. Then I want to assign the id to a new setting.