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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
NeedAnswers
  • 1,411
  • 3
  • 19
  • 43
  • 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 ! – NeedAnswers May 13 '14 at 03: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. – Ryan Gates May 13 '14 at 03:20
  • sorry i don't have enough reputation ! – NeedAnswers May 13 '14 at 03:26
  • The ability to create a post starts at `1` reputation, take a look at the [privileges](http://stackoverflow.com/help/privileges?tab=creation). – Ryan Gates May 13 '14 at 03:55
  • Now You can answer here. :p –  May 13 '14 at 04:57

1 Answers1

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

NeedAnswers
  • 1,411
  • 3
  • 19
  • 43
  • 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?! – vapcguy Jun 14 '16 at 16:33