2

I'm experiencing this trouble that I can't figure out a solution.

I have a asp.net website project. A class library in app_code folder named Libs.cs (class name is Libs too).

The problem is :

  • if I want to reference the class in *.aspx.cs files, I have to set its Build Action property to : compile. This way I can reference the class without using the using Synxtax ( for example my namespace is IK, I don't have to include : using IK; ) , but I can't reference the class in the .aspx file

  • if I want to reference the class in *.aspx files, I have to set its Build Action property to : content. This way I can reference the class using the import Syntax ( for example my namespace is IK, I have to include : <%@ Import Namespace="IK" %> ), but I can't reference the class in the .aspx.cs file

So now if I want to reference the class, I have to choose , aspx or aspx.cs. I tried to google and everything, but without success.

5
  • Got it! I created this project using : new-> new website project-> empty asp.net website project but i don't know somehow it became Web Application Project so using the app_code folder for containing class files is wrong the solution is creating another folder for the classes thanks for reading ! Commented May 13, 2014 at 3:15
  • If you found the solution to your question, please post it as an answer so that other people can learn from it as well. Commented May 13, 2014 at 3:20
  • sorry i don't have enough reputation ! Commented May 13, 2014 at 3:26
  • The ability to create a post starts at 1 reputation, take a look at the privileges. Commented May 13, 2014 at 3:55
  • Now You can answer here. :p Commented May 13, 2014 at 4:57

1 Answer 1

1

Got it!

I created this project using : new-> new website project-> empty asp.net website project

but i don't know somehow it became Web Application Project

so using the app_code folder for containing class files is wrong

the solution is creating another folder for the classes

thanks for readin

Sign up to request clarification or add additional context in comments.

1 Comment

Had the exact same problem after reverting to .NET 4.0 from 4.5.2 (target server wasn't getting upgraded yet, so had to compile for a lower version) and I've found that creating another folder and moving the code there works. Now, the ultimate question is "WHY?"! The files being in the App_Code folder or in a standard folder should not matter - at least to me. Anyone know why it does?!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.