MOSS Forum

Ask Question   UnAnswered
Home » Forum » MOSS       RSS Feeds

Why can't I create a Web app in LAYOUTS directory?

  Asked By: Nilay    Date: Sep 02    Category: MOSS    Views: 1890

My developer's baby decided to come early (like a month) so I have to do a
little coding in MOSS. What I want to do is access the current user profile
properties (name, memberOf, audience, etc ...) to determine if we can use
those values in an application we are designing for re-write (not pretty,
just raw data values).

So, in v2, I just create a directory in the _layouts folder and start
building a new application. When I try to do that in MOSS using Visual
Studio 2005, I get the following error:
"Unable to create the Web ....... Server error: The folder
"/_layouts/<project name>" is reserved for use by the Web server. A Web may
not be created under this URL"

If I can't put it there, then where? I want to take advantage of the
SharePoint API.



13 Answers Found

Answer #1    Answered By: Dorothy Farmer     Answered On: Sep 02

You can still create  a web  application within the "_layouts"
directory. I find the best way is to create a website in VS2005 and specify
it as a file system site and create it within the "_layouts" directory. I
can then add references to the SharePoint Namespaces as before and hey
presto. The only other thing you need to do is to make sure within IIS that
your folder  is declared as a web application  (virtual directory). This might
not be the best way of doing it but for "down and dirty" coding  works a

Answer #2    Answered By: Jacklyn Burnett     Answered On: Sep 02

I'll give that a try...............

Answer #3    Answered By: Breann Beach     Answered On: Sep 02

Using _layouts  to create  applications isn't really the SharePoint model
unless your goal to have your "application pages" available to all WSS
v3 Web Applications? If you can target a single Web Application, you are
better off using a virtual directory  directly off the home directory for
the IIS Web Site. It is auto-excluded in WSS v3.

If you can structure your solution in Web Parts that can live on any WSS
page, that is even better.

Answer #4    Answered By: Irving Hurley     Answered On: Sep 02

We have a custom app  in our v2 environment that is a series of 18 Web parts.
Obviously, this is not ideal since, in my opinion anyway, a Web part is a
single function piece and is not ideal when it takes 18 of them to perform
the task. In essence, the application  is for creating and tracking
notifications (events, tasks, and notifications) for each of our 300+
locations with ~2000 recipients. The intent in moving it to v3 is to take
advantage of the user  profiles and all the AD attributes that make up the
profile for each user, effectively removing all the custom code currently in
place for identity and role. We have other classes in our framework for data
access so if this can work, we will reduce the custom code from 40,000 lines
(yeah, that's a bunch - I suspect the offshore company that developed
it thought they were getting paid per line of code :) ) to ... well, a bunch

My thought on this is to custom develop the functionality that cannot be
achieved through the SharePoint API as a true application, chromeless, and
use a page viewer Web part to point at it's location. This would facilitate
easier enhancements and a lot less support time and effort. The logical
place for this to reside is the /_layouts directory. If I put it in the root
directory of the Web site, will that pose additional problems or things to
be aware of?

Answer #5    Answered By: Vinay Thakur     Answered On: Sep 02

Facinating, take the following points as just my gut reaction (vs. a
well thought out response):

First, why use MOSS profiles when you have AD groups and attributes? How
will that trim your custom code requirements?

Second, if you use audience  (not my recommendation) be sure to stay true
to the use of audience as a filter not a security mechanism.

Third, the Page Viewer Web Part is more than just clunky. While it has
its place, hand rolling something won't cost more than a hundred lines
of code or so and will result in a much better GUI.

Forth, consider using a Module and CustomAction Feature rather than a
hardcoded Web application  in _layouts. The allows you to put ghosted
virtual pages where you need them based upon an activation at a given

Fifth, if you don't use a Feature, using an IIS virtual directory  in a
specific Web Application rather than something in _layouts  limits the
solution to only that Web Application. It also doesn't tangle
non-SharePoint code within the 12 hive. There may be caveats that I
don't know to tell you about, but that could be true of a _layouts
solution too.

Answer #6    Answered By: Osvaldo Winters     Answered On: Sep 02

I will look harder at your fourth suggestion - I assume your latest book
dives into that a little?

Answer #7    Answered By: Alisha Itagi     Answered On: Sep 02

It does but only at the introductory level. See the Features chapter.

Answer #8    Answered By: Brianna Olson     Answered On: Sep 02

Creating an webapplication in sharepoint context(in /_layouts) is quite
and you can access  context user  and extend the SharePoint object model as per
your requiement.

Just clarify two quick questions,

1. you want to create  a web-app in /_layouts directory  is it mandatory. or
2. just accessing your custom written pages using your sharepoint site from
/_layouts is enough

Answer #9    Answered By: Allyson Burgess     Answered On: Sep 02

The location of the applicaiton is not mandated - I assumed it was needed to
extend the object model as I've described in my earlier post.

Answer #10    Answered By: Faith Delgado     Answered On: Sep 02

ok then, you just create  a seperate directory  under /_layouts and put your
custom pages in that directory. access  pages from sharepoint site with path.

I hope this works for you.

Answer #11    Answered By: Elaine Mack     Answered On: Sep 02

I have some pages in my project working very well under _layouts, for
the project&deployment setup look into the sources
the code is up on codeplex

I didnt create  a subfolder under _layouts  for .aspx pages, but i could
have. Actually, i would have liked the pages to be directly accessible
from the "FEATURE" folder, anyone knows how to do that ?

Answer #12    Answered By: Baiju Hoskeri     Answered On: Sep 02

Use a Module Feature to pretend copy (Ghostable) the page to a virtual
location within every Web where the Feature is activated. For instance:

<Module Name="Default" Url="InDatabase" Path="OnDisk">
<File Url="MyPage.aspx" Type="Ghostable" />

This will pretend copy a physical, file-system-based ASPX page called
MyPage.aspx from a relative folder  called OnDisk to a virtual folder
called InDatabase on every Web that the Feature is activated within. So,
once installed and activated, you could browse to
http://domain/InDatabase/MyPage.aspx or
domain/sites/CoolSite/InDatabase/MyPage.aspx and both would
reference the file in the OnDisk directory  on the file system.

Answer #13    Answered By: Kristy Hicks     Answered On: Sep 02

i will try it out, sounds like the cleanest solution.
BTW, some people have asked me for source availability, its all there
under MIT licence, the problem is that CodePlex source servers happen
to be down.

Didn't find what you were looking for? Find more on Why can't I create a Web app in LAYOUTS directory? Or get search suggestion and latest updates.