I have an ASP.Net MVC Portable Are project that contains clean C # code, Razor views (cshtml), javascript and CSS. All of this is embedded in the output DLL for the project area.
I want to create an @helper function that can be accessed through cshtml views in this area, and I followed Scott Gu's blog post to configure this. According to Visual Studio intellisense and the compiler, everything was fine when I tried to access the helper, like this:
@Helpers.MyMethod("myInput");
But when I tried to run the application, I got a runtime error indicating that
The name "Helpers" does not exist in the current context "
I placed the Helpers.cshtml file in the App_Code folder in the root folder of my MVC project with portable areas and set the build action to "Embedded resource" (as I need to do with the rest of my cshtml files).
Instead, I tested the Helpers.cshtml file in the App_Code folder of my ASP.Net MVC application project, and then it worked fine, but itβs not possible to have an assistant in the application project because I donβt want to use dependencies on the application area.
It also works to rewrite @helper into @function and put it inside each of the CSHTML views, but I would like to avoid duplication for each view.
, Helpers , , , .