TK Lim

TK Lim

  • NA
  • 10
  • 10.9k

MVC C#: System.InvalidOperationException

Oct 28 2014 6:16 PM


 I am new to MVC C#. I am building my project based on the MVC Music Store tutorial.

 I have the following code which throw the following error message during runtime. Please tell me how to handle the null value in my code.
[error message] 
 An exception of type 'System.InvalidOperationException' occurred in System.Core.dll but was not handled in user code
 [/error message]
 
[code] 

public ActionResult SubCategory(int? s_catid)

{

var subcategories = db.Categories.Include("Sub_Categories").Single(s => s.C_Catid == s_catid);

return View(subcategories);

}

 [/code]
 
Thanks and regards.
TK 

Answers (2)