Newbie in C# This is my code. and during debugging i get to this method with out error! but when it send the request back i get back the error listed above! so any ideas how to solve this? thanks
[HttpPost]
public ActionResult Delete(int auctionId, int productId)
{
Auction auct = auctionRepository.Auctions.FirstOrDefault(a => a.AuctionID == auctionId);
if (auct != null) {
auctionRepository.DeleteAuction(auct);
TempData["message"] = string.Format(auct.AuctionID + " was deleted");
}
return RedirectToAction("Edit", "Admin", new { productId });
}
/////////
error =>
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 6: }
Line 7:
Line 8:
<h2>Edit @Model.Title</h2>
Line 9: @using (Html.BeginForm("Edit", "Admin",FormMethod.Post, new { enctype = "multipart/form-data" })) {
Line 10: @Html.EditorForModel()