NeedAnswers NeedAnswers - 13 days ago 6
ASP.NET (C#) Question

Can't access class from app_code folder in asp.net webiste project

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 dont 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
    Synxtax ( 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.

Answer

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