ASP.Net directory structure

  • Thread starter Centron System Solutions
  • Start date
C

Centron System Solutions

Hello all

Im using ASP.Net VS2005

I want to craete a directory structure for my new Website project.

If I put classes inside "APP_Code" folder I have no problem accessing
that code from code behind files.

However if I create any other folder and put a class inside I get the
following type of build error

"The Type or namespace name 'Class2' could not be found (are you
missing a using directive......)"

What are the mechanics of creating a directory structure and allowing
the code there in to be used in code behind files?

Thanks for any help in advance.

Regards

Denis
 
M

Mark Fitzpatrick

Denis,
You're using a Web Site Project, and this is one of the draws against them.
The thing to keep in mind with this project type is you are not compiling
your web site into a single dll, that's a Web Application Project. In the
Web Site Project you are creating dlls for files in the various directories.
The directories therefore have lots of dlls and are not compiled all at the
same time. So, your App_Code exists to avoid this by getting compiled first,
then you're able to use it in the other folders. Code in the other folders
gets compiled in a different order so that Folder B should be compiled
before Folder X. If you have code in Folder X that references a class in
Folder B, you'll be OK since it's already compiled. Try to reference code in
Folder X from Folder B and you'll get errors because Folder X is compiled
after.

The easiest thing to do then with Web Site projects is to place all common
code in the App_Code directory. Alternateively, you can use the Web Site
Project which will just take all the code and compile it ino a single dll
for the project. This was the original project type for Visual Studio, but
in VS 2005 was replaced by the web site project. After much outcry it was
made available again as an add-in, then rolled into VS 2005 Service Pack 1.
If you have VS 2005 SP1 you'll have this project type under New | Projects |
language choice (C# or VB) | Web | Web Application Project. The only
drawback is the membership profile provider needs an add-in in order to
generate the necessary classes to support any profile definitions you have
in the membership user profile definition in the web.config.

Hope this helps,
Mark Fitzpatrick
 
H

Hillbilly

Mark, could you please explain more about the needed add-in for Membership
or point to the blog where it may be downloaded (if necessary)? I now use
VS2008, is it still required? I've been using Web Sites and have been
considering trying Web Application Projects and use Membership frequently.
 
M

Mark Fitzpatrick

Yes, the web application project type itself needs this add-in to generate
the profile classess needed. In the web site project type, if you create a
membership profile, the configurations that you put into the web.config for
it are generated on the fly. Since the web app project is compiled, the
profile gets broken. There's an add-in at:
http://www.codeplex.com/WebProfile It's been around since VS 2005 and
hasn't been updated in years, but I don't think it needs any updating
because it does a fairly specific job, generating the classes you need so
you can work with the asp.net profile provider. VS 2008 would also need it
since it's an inherent issue with the web app project.

Hope this helps,
Mark Fitzpatrick
 
H

Hillbilly

thankyou.aspx

Mark Fitzpatrick said:
Yes, the web application project type itself needs this add-in to generate
the profile classess needed. In the web site project type, if you create a
membership profile, the configurations that you put into the web.config
for it are generated on the fly. Since the web app project is compiled,
the profile gets broken. There's an add-in at:
http://www.codeplex.com/WebProfile It's been around since VS 2005 and
hasn't been updated in years, but I don't think it needs any updating
because it does a fairly specific job, generating the classes you need so
you can work with the asp.net profile provider. VS 2008 would also need it
since it's an inherent issue with the web app project.

Hope this helps,
Mark Fitzpatrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top