Class files in App_Code folder cannot be accessed from other pages in Web application project

               
                
               I have faced this problem multiple times and each time i found some solutions from Internet and go on with it. So I thought this time I will post it on the blog so next time I don't have to look somewhere else. Also it will be helpful for others.
               We usually hear that class file in the project must put in App_Code folder. Actually this will work with Website projects in ASP.NET. In case of Web application project When we compile the Web application project, it won't include all file. This is the reason we can't access the class files in App_Code folder from other pages (because this file are not compiled). So to import a class file from App_Code folder in a WAP, we need to taken properties of class file in App_Code folder. Properties window will open as shown in image below.


                 In properties window "Build Action" is set to "Content" as default. Change this option to "Compile" from the options.

Options available in "build action"


 

Now Rebuild the project and the class file will be available to call from other pages in the project. All you need is to import App_Code folder in the page.

Comments

Popular posts from this blog

FIX: Severity Code Description Project File Line Suppression State Error Web deployment task failed.

FIX Web Deploy from visual studio failed with error ERROR_EXCEEDED_MAX_S...

Add/Remove automatic password expiration of MS SQL user