سؤال

BlogEngine.NET is setup in the root directory of my webhost (DiscountASP.NET). I am trying to setup a personal wiki in a subdirectory (www.mydomain.com/wiki).

The wiki folder is setup as a web application in IIS. www.mydomain.com/wiki shows:

Server Error in '/wiki' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name 'BlogEngine' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 103:      </controls>
Line 104:      <namespaces>
Line 105:        <add namespace="BlogEngine.Core" />
Line 106:      </namespaces>
Line 107:    </pages>

So the webserver looks at the web.config of the root application before sending the request to the application in the subfolder. Why it can not find the bins now (which work fine when hitting www.mydomain.com), I'm not sure.

How can I setup the subfolder application so it's independent of the application installed in the root folder?

هل كانت مفيدة؟

المحلول 2

Conclusions after reading up on this: First off, If you have control over all IIS, it should be easy to set up an app in a subdirectory via App Pools and Virtual Directories.

The problem with doing it without virtual directories, and just put it in a subdirectory in the physical file system is that web.config in the subdirectory will be inheriting from the web.config in the root directory.

In some cases this can be solved by using and tags in the web.config in the subdirectory to remove the inherited things. It was a bit too arcane for my taste.

One way around this is to put all apps in separate subdirectories (/blog /wiki etc) and then use Url Rewriting on the app you want in the root directory. In my case I used the rules:

^(?!(wiki|blog)).+

and

^&

to point to /blog (appending the original query string).

نصائح أخرى

Blog Engine is at your site: http://blog.discountasp.net/ subdomain not root :)

Well at least your domain DNS records are set up that way.

Need a separate app_pool thats the magic to get BE to play well with the others :)

So you need 3 app_pools

  1. For BE Engine
  2. For your main site www.discountasp.net
  3. For your Wiki

Doing this they won't mess with each other they are treated as 3 completely different apps.

In your main "Root" web.config make sure its set to allow web.config in sub folders.

But, not sure if this is needed for if you have your own app_pools.

What I did was I added a location tag at the end of the web.config file for BlogEngen.Net which removed the settings for the sub-folder.

<location path="wiki" allowOverride="true">
<connectionStrings>
    <remove name="BlogEngine"/>
    <add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
    <compilation debug="false" targetFramework="4.0">
        <assemblies>
            <remove assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <remove assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <remove assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <remove assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <remove assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <remove assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <remove assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <remove assembly="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <remove assembly="System.Web.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <remove assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <remove assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <remove assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        </assemblies>
        <expressionBuilders>
            <remove expressionPrefix="LinqLength"/>
            <remove expressionPrefix="Reflect"/>
            <remove expressionPrefix="Session"/>
            <remove expressionPrefix="Server"/>
            <remove expressionPrefix="QueryString"/>
            <remove expressionPrefix="Code"/>
        </expressionBuilders>
    </compilation>
    <membership defaultProvider="AspNetSqlMembershipProvider">
        <providers>
            <clear/>
            <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
        </providers>
    </membership>
    <roleManager defaultProvider="AspNetSqlRoleProvider">
        <providers>
            <clear/>
            <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
            <add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        </providers>
    </roleManager>
    <siteMap defaultProvider="AspNetXmlSiteMapProvider">
        <providers>
            <add siteMapFile="web.sitemap" name="AspNetXmlSiteMapProvider" type="System.Web.XmlSiteMapProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </providers>
    </siteMap>
    <httpModules>
        <remove name="WwwSubDomainModule"/>
        <remove name="UrlRewrite"/>
        <remove name="CompressionModule"/>
        <remove name="ReferrerModule"/>
        <remove name="SecurityModule"/>
        <remove name="RightModule"/>
    </httpModules>
    <httpHandlers>
        <remove verb="*" path="file.axd"/>
        <remove verb="*" path="image.axd"/>
        <remove verb="*" path="syndication.axd"/>
        <remove verb="*" path="sitemap.axd"/>
        <remove verb="*" path="trackback.axd"/>
        <remove verb="*" path="pingback.axd"/>
        <remove verb="*" path="opensearch.axd"/>
        <remove verb="*" path="metaweblog.axd"/>
        <remove verb="*" path="rsd.axd"/>
        <remove verb="*" path="css.axd"/>
        <remove verb="*" path="js.axd"/>
        <remove verb="*" path="res.axd"/>
        <remove verb="*" path="rating.axd"/>
        <remove verb="*" path="opml.axd"/>
        <remove verb="*" path="blogml.axd"/>
        <remove verb="*" path="sioc.axd"/>
        <remove verb="*" path="apml.axd"/>
        <remove verb="*" path="foaf*.axd"/>
        <remove verb="*" path="*.htm"/>
    </httpHandlers>
</system.web>
<system.webServer>
    <modules>
        <remove name="WwwSubDomainModule"/>
        <remove name="UrlRewrite"/>
        <remove name="CompressionModule"/>
        <remove name="ReferrerModule"/>
        <remove name="SecurityModule"/>
        <remove name="RightModule"/>
    </modules>
    <handlers>
        <remove name="FileHandler"/>
        <remove name="ImageHandler"/>
        <remove name="Syndication"/>
        <remove name="Sitemap"/>
        <remove name="Trackback"/>
        <remove name="Pingback"/>
        <remove name="OpenSearch"/>
        <remove name="MetaWeblog"/>
        <remove name="RSD"/>
        <remove name="CssHandler"/>
        <remove name="Javascript"/>
        <remove name="Resource"/>
        <remove name="Rating"/>
        <remove name="Opml"/>
        <remove name="BlogML"/>
        <remove name="SIOC"/>
        <remove name="Apml"/>
        <remove name="Foaf"/>
        <remove name="Html"/>
    </handlers>
</system.webServer>

If you use this and have more sub-folders you need to add it for each of them.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top