I'm new in C# and espacially in ASP.NET MVC.
I have my HomeController, which contains this method:
public ActionResult Error(Error error)
{
return View(error);
}
Now I have another Controller, which have the following line inside:
return RedirectToAction("Error","Home", new { Error = (new Error("ErrorName","ErrorDescription"))} );
As you might notice, I am trying to pass an Error object to the other controller, which then should pass it to the View.
The Error class I have written on my own, nothing spectacular:
public class Error
{
public String name { get; private set; }
public String description { get; private set; }
public int number { get; private set; }
public Error(String name, String description)
{
this.name = name;
this.description = description;
number = 0;
}
}
My problem ist that every time I try to access the error Variable in the HomeController, it is null
.
I have already googled an found some posts, but I don't understand, why my code isn't working.
There are no errors, just this null value object..
I Appreciate any help! :)