2
Answers

MVC C#: System.InvalidOperationException

TK Lim

TK Lim

10y
4.1k
1


 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)