Search code examples
asp.net-mvc-3entity-framework-4

ASP.NET MVC 3 and App_Code folder


In ASP.NET Webform, App_Code is the standard folder for putting code and using it at run-time. But I think this folder is kind of different in ASP.NET MVC, my question is:

  • where should I put my code ( Extension methods, Helpers, ... ) in ASP.NET MVC. When I store code in App_Code folder, I can't use them in controller but they work fine in views.

  • About Entity Framework, the same question, where should I put edmx and tt files? I'm not using Code-First

Update:

After some search, finally I created a new Class Library project in my solution, code is available in all controllers and views. I still don't know why the code in App_Code is not available in the controller


Solution

  • I had the same issue, my class Utility.cs was not recognized inside my MVC project. I changed the Build Action "Content" to "Compile" and that solved my problem. Hope that helps.