App not running from sub folder

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

My asp.net is in the Events sub folder of the root folder. In the root
folder I have a web.config file which has the following code under
system.web section;

<authentication mode="Forms">
<forms name="LoginAuthCookie" loginUrl="~/Events/Login.aspx" />
</authentication>

However when I enter the url http://localhost/Events/, I get the below
error;

Directory Listing Denied
This Virtual Directory does not allow contents to be listed.

What am I missing and why does the login.aspx form not come up?

Thanks

Regards
 
All you've done there is told it to go look for a Login.aspx file in that
folder. You need to restrict access to that folder or another folder in
order for the user to be redirected to the login page. You need to set the
authorization node in the web.config.

The error you are seeing is from the web server, not ASP.Net. What it's
telling you is there is no default file to display in the events directory.
All web servers have default filenames that they use and look for when you
enter a directory name without any filename. If you had a file called
Default.aspx in that directory, then IIS should find it and show it to you.
Since you don't have a default file there, IIS is telling you that you
cannot view a list of files for that directory (the not allow contents to be
listed part of the error). This is a security feature that's been
implemented by default for a long time now to avoid users from digging
around to any file in a directory when a default file isn't present.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression
 
Hi

I have added a menu.aspx form to the Events folder and trying to access it
via http://localhost/Events/menu.aspx I am hoping to get the
~/Events/Login.aspx form appear first but I get;

Server Application Unavailable
The web application you are attempting to access on this web server is
currently unavailable. Please hit the "Refresh" button in your web browser
to retry your request.

Any ideas?

Thanks

Regards
 
I am getting the below event in event log;

Thanks

Regards

Event Type: Error
Event Source: ASP.NET 2.0.50727.0
Event Category: None
Event ID: 1334
Date: 18/05/2008
Time: 02:54:54
User: N/A
Computer: MYPC
Description:
Failed to initialize the AppDomain:/LM/W3SVC/1/ROOT

Exception: System.Configuration.ConfigurationErrorsException

Message: Exception of type
'System.Configuration.ConfigurationErrorsException' was thrown.

StackTrace: at
System.Web.Configuration.ErrorRuntimeConfig.ErrorConfigRecord.System.Configuration.Internal.IInternalConfigRecord.GetLkgSection(String
configKey)
at System.Web.Configuration.RuntimeConfigLKG.GetSectionObject(String
sectionName)
at System.Web.Configuration.RuntimeConfig.GetSection(String sectionName,
Type type, ResultsIndex index)
at System.Web.Configuration.RuntimeConfig.get_HostingEnvironment()
at System.Web.Hosting.HostingEnvironment.StartMonitoringForIdleTimeout()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager
appManager, IApplicationHost appHost, IConfigMapPathFactory
configMapPathFactory, HostingEnvironmentParameters hostingParameters)
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager
appManager, IApplicationHost appHost, IConfigMapPathFactory
configMapPathFactory, HostingEnvironmentParameters hostingParameters)
at
System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(String
appId, IApplicationHost appHost, HostingEnvironmentParameters
hostingParameters)
at
System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironmentAndReportErrors(String
appId, IApplicationHost appHost, HostingEnvironmentParameters
hostingParameters)
 
Is the /Events directory a virtual directory in IIS or an IIS application ?

If not, the ~/Events link will never find the proper place because
the " ~ " refers to the root of an IIS application or to a virtual directory.




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
Events is a normal folder under the root folder. Its actual path is
C:\Inetpub\wwwroot\Events. The reason I kept it that way is when I'll move
the app to remote web host then that folder would be a normal folder under
web root folder as well. Any way to fix this without making it a virtual
folder or application? Why do I need to make it anything different when it
is not the root folder?

Thanks

Regards
 
re:
!> Any way to fix this without making it a virtual folder or application?

Just don't reference it as "~/Events". Use "/Events" in the link.

If you use the tilde, ASP.NET interprets it as "look for the root folder of the application".
Since the /Events directory is not an application root, the link leads nowhere.

!> Why do I need to make it anything different when it is not the root folder?

You need to do it *precisely* because it's not the root folder of your app.
If /Events was the root application folder, the "~/Events" link would take you there.

See above.




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
Back
Top