I am new to C # and espacially in ASP.NET MVC.
I have my HomeController that contains this method:
public ActionResult Error(Error error) { return View(error); }
Now I have another controller that has the following line inside:
return RedirectToAction("Error","Home", new { Error = (new Error("ErrorName","ErrorDescription"))} );
As you may have noticed, I'm trying to pass an Error object to another controller, which then needs to pass it to the view.
The error class that I wrote myself is nothing impressive:
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 is that every time I try to access the Variable variable in the HomeController, it is null . I already found google to search for posts, but I donβt understand why my code is not working. No errors, only this object with a zero value. I appreciate any help! :)
source share