Code runs in root dir, but not sub dir
<p>Im having some strange trouble. </p>

<p>I  have a piece of code</p>

<pre><code> &lt;%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs"     Inherits="_Default" %&gt;

    &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

    &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;head runat="server"&gt;
        &lt;title&gt;VERSIONS CHECK!!!&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;form id="form1" runat="server"&gt;
        &lt;div&gt;
            &lt;asp:Label ID="lblVersion" runat="server" /&gt;
        &lt;/div&gt;
        &lt;br /&gt;
        &lt;div&gt;
            &lt;asp:Label ID="lblHelloWorld" runat="server" /&gt;
        &lt;/div&gt;
        &lt;p&gt;
            &lt;asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /&gt;
       &lt;/p&gt;
        &lt;/form&gt;
    &lt;/body&gt;
    &lt;/html&gt;
</code></pre>

<p>and the codebehind file:</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
{
    lblVersion.Text = System.Environment.Version.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
    if (lblHelloWorld.Text.Equals(string.Empty))
    {
        lblHelloWorld.Text = "Hello World";
    }
    else
    {
        lblHelloWorld.Text = "";
    }
}
}
</code></pre>

<p>This works both locally, and in my public_html folder. But if I put the same in subfolders, like <code>public_html/folder1/folder2</code> it comes with an error.</p>

<pre><code>Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error     settings for this application prevent the details of the application error  from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a &lt;customErrors&gt; tag within a "web.config" configuration file located in the root directory of the current web application. This &lt;customErrors&gt; tag should then have its "mode" attribute set to "Off".
&lt;!-- Web.Config Configuration File --&gt;
&lt;configuration&gt;
    &lt;system.web&gt;
        &lt;customErrors mode="Off"/&gt;
    &lt;/system.web&gt;
&lt;/configuration&gt;
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's &lt;customErrors&gt; configuration tag to point to a custom error page URL.
&lt;!-- Web.Config Configuration File --&gt;
&lt;configuration&gt;
    &lt;system.web&gt;
        &lt;customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/&gt;
    &lt;/system.web&gt;
&lt;/configuration&gt;
</code></pre>

<p>Im brand new to ASP.NET and publishing with visual studio - so chances is that im doing something wrong somewhere. Actually this is my first attempt on writing ASP.NET - so be gently :)</p>

<p>Thx in advance.</p>

<p><strong>Jack this is how my config file looks now:</strong></p>

<p>
Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\vx.x\Config 
-->
    
    
    </p>

<pre><code>&lt;system.web&gt;
    &lt;compilation debug="true" targetFramework="4.0"&gt;
    &lt;/compilation&gt;
    &lt;authentication mode="Windows"/&gt;


&lt;customErrors mode="Off" defaultRedirect="GenericErrorPage.htm"&gt;
&lt;error statusCode="403" redirect="NoAccess.htm" /&gt;
&lt;error statusCode="404" redirect="FileNotFound.htm" /&gt;
&lt;/customErrors&gt;
&lt;pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/&gt;
&lt;/system.web&gt;
&lt;/configuration&gt;
</code></pre>

<p>And the error i get now is:</p>

<p>Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.</p>

<p>Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS.</p>

<p>Source Error:</p>

<pre><code>Line 26:             ASP.NET to identify an incoming user. 
Line 27:         --&gt;
Line 28:        &lt;authentication mode="Windows"/&gt;
Line 29: 
Line 30: 
</code></pre>
