Problem with accessing class in APP_CODE folder

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I am trying to use APP_CODE folder for all my class files under VS 2005.
After adding APP_CODE in the solution explorer, I added a new web page by
right clicking project and selecting add new item. I expected the code
behind file (Default.aspx.cs) to automatically go under APP_CODE folder, but
it didnt. I tried to drag and drop the code behind file into the APP_CODE
folder. I also changed the page directive to the following:

<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="~/App_Code/Default.aspx.cs" Inherits="Default" %>

I also tried the follwing page directive

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>

The problem that I am facing is the error that I get when I build the
solution. Following is the error

Error 1 The file '/Todelete/App_Code/Default.aspx.cs' is in the special
directory 'App_Code', which is not allowed.

I have searched for this error in the internet but didn't get a solution.
Can anybody please help me here. How can I make the code behind file to
reside inside my APP_CODE folder.

thanks
pradeep
 
you've created a codebehind file. (Default.aspx.cs)

these don't automatically go into the APP_Code folder, they reside in the same directory as the parent page.

the naming of the file should be something other than the parent page name then you can place it in the APP_code folder.
 
Hi,

pradeep_TP said:
Hello,

I am trying to use APP_CODE folder for all my class files under VS 2005.
After adding APP_CODE in the solution explorer, I added a new web page by
right clicking project and selecting add new item. I expected the code
behind file (Default.aspx.cs) to automatically go under APP_CODE folder, but
it didnt. I tried to drag and drop the code behind file into the APP_CODE
folder. I also changed the page directive to the following:

<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="~/App_Code/Default.aspx.cs" Inherits="Default" %>

I also tried the follwing page directive

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>

The problem that I am facing is the error that I get when I build the
solution. Following is the error

Error 1 The file '/Todelete/App_Code/Default.aspx.cs' is in the special
directory 'App_Code', which is not allowed.

I have searched for this error in the internet but didn't get a solution.
Can anybody please help me here. How can I make the code behind file to
reside inside my APP_CODE folder.

thanks
pradeep

I am also a maniac, welcome to the club :-) I prefer to have my source
code files placed somewhere else than the web application root, but...
it's not as easy in 2.0 as it was in 1.1

http://geekswithblogs.net/lbugnion/archive/2006/09/12/91000.aspx

Greetings,
Laurent
 
Back
Top