I have a .Net 4.0 project called BasicTestProject and it contains a webform called Default.
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="BasicTestProject.Default" %>
Default.aspx.cs:
namespace BasicTestProject
{
public partial class Default : System.Web.UI.Page
{
...
}
}
I want to put a compiled version of this application in the subfolder of a website:
- Website Root
- SubFolder
- BasicTestProject
- SubFolder
At the Website Root I have a basic web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation targetFramework="4.0" />
</system.web>
</configuration>
I made a test of the example above and when I try to access the site within a Subfolder (http://WebsiteRoot/SubFolder/BasicTestProject/Default.aspx), this is the error I am getting:
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'BasicTestProject.Default'.
Source Error:
Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="BasicTestProject.Default" %>
Line 2:
Line 3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Source File: /*WebsiteRoot*/*SubFolder*/BasicTestProject/default.aspx Line: 1
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
Also, I should mention that I have tried placing my compiled BasicTestProject on its own IP address so that it sits at the root folder. That works as expected and I can access Default.aspx.
UPDATE (answer):
In IIS7 I right-clicked BasicTestProject and converted it in to an application.
- Website Root
- SubFolder
- BasicTestProject
- SubFolder
I had to also grant the Application Pool user permission to the BasicTestProject folder. It is now self-contained and running.
I’ll elaborate on @MikeC’s answer a bit: In IIS there is the concept of “application scope” which is a sub-hierarchy of the filesystem tree which belongs to the same conceptual “application”.
The root of every individual IIS website is also marked as the root of a new application scope. Any server-side code that is executed in a scope runs in the Application Pool that the scope belongs to (CGI and FastCGI processes are launched under the identity of the scope’s pool, for example). ASP.NET takes this further by defining the root of an application scope to be where it expects to find the
bindirectory as well as allowing moreweb.configoptions to be defined.As I said, this applies to the filesystem hierarchy, so if you’re using URL Rewriting or ASP.NET URL Routing then it complicates things.
(This was originally a comment reply to Mike’s answer, but it overran the message length).