error compiling Visual Studio

Topics: ASP.NET 2.0
Jan 24, 2008 at 8:28 PM
The 'MachineToApplication' error has been discussed quite a few times in this forum. Unfortunately, none of the solutions helped.

I have added blogEngine as a sub-domain. My main directory is an Ektron CMS, so it has a really complex web.config. I have removed all of the components that were breaking the BE from working. I have set-up the Blog folder as an application in IIS. The application runs just fine and the application works beautiful. I set-up the site to use SQL Server. That is also working just fine.

The problem occurs when I enter debug mode in Visual Studio. No matter what page I am in, I get the following error.

Thanks for your help!
cyfer213

Error 112 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. C:\Inetpub\nexthome\next1005\Blog\Web.Config 11

<?xml version="1.0"?>
<configuration>

<configSections>
<sectionGroup name="BlogEngine">
<section name="blogProvider" requirePermission="false" type="BlogEngine.Core.Providers.BlogProviderSection, BlogEngine.Core" allowDefinition="MachineToApplication" restartOnExternalChanges="true"/>
</sectionGroup>
</configSections>

<BlogEngine>
<blogProvider defaultProvider="MSSQLBlogProvider">
<providers>
<add name="XmlBlogProvider" type="BlogEngine.Core.Providers.XmlBlogProvider"/>
<add name="MSSQLBlogProvider" type="BlogEngine.Core.Providers.MSSQLBlogProvider"/>
</providers>
</blogProvider>
</BlogEngine>
<connectionStrings>
<add name="BlogEngine" providerName="System.Data.SqlClient" connectionString="server=XXXXX;database=XXXXX;Integrated Security=false;user=XXXXX;pwd=XXXXX;"/>
</connectionStrings>


<!-- configSource is not implemented in Mono.
<connectionStrings configSource="sql.config" />
-->


<appSettings>
<add key="BlogEngine.FileExtension" value=".aspx" />
<!-- You can e.g. use "~/blog/" if BlogEngine.NET is not located in the root of the application -->
<add key="BlogEngine.VirtualPath" value="~/" />
<!-- The regex used to identify mobile devices so a different theme can be shown -->
<add key="BlogEngine.MobileDevices" value="(nokia|sonyericsson|blackberry|samsung|sec-|windows ce|motorola|mot-|up.b)" />
</appSettings>

<system.web>
<compilation debug="true" />
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="auto" uiCulture="auto" />
<httpRuntime enableVersionHeader="false" useFullyQualifiedRedirectUrl="true" maxRequestLength="16384" executionTimeout="3600" requestLengthDiskThreshold="16384" />

<machineKey
validationKey="D9F7287EFDE8DF4CAFF79011D5308643D8F62AE10CDF30DAB640B7399BF6C57B0269D60A23FBCCC736FC2487ED695512BA95044DE4C58DC02C2BA0C4A266454C"
decryptionKey="BDAAF7E00B69BA47B37EEAC328929A06A6647D4C89FED3A7D5C52B12B23680F4"
validation="SHA1" decryption="AES"
/>

<authentication mode="Forms">
<forms timeout="129600" name=".AUXBLOGENGINE" protection="All" slidingExpiration="true" loginUrl="~/login.aspx" cookieless="UseCookies" />
</authentication>

<pages enableSessionState="false" enableViewStateMac="true" enableEventValidation="true">
<controls>
<add namespace="Controls" tagPrefix="blog"/>
</controls>
</pages>
<customErrors mode="Off"/>

<membership defaultProvider="XmlMembershipProvider" >
<providers>
<clear />
<add name="XmlMembershipProvider" type="BlogEngine.Core.Providers.XmlMembershipProvider, BlogEngine.Core" description="XML membership provider" xmlFileName="~/App_Data/users.xml"/>
</providers>
</membership>

<roleManager defaultProvider="XmlRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".BLOGENGINEROLES">
<providers>
<clear />
<add name="XmlRoleProvider" type="BlogEngine.Core.Providers.XmlRoleProvider, BlogEngine.Core" description="XML role provider" xmlFileName="~/App_Data/roles.xml"/>
</providers>
</roleManager>

<siteMap defaultProvider="PageSiteMap" enabled="true" >
<providers>
<add name="PageSiteMap" description="The site map provider that reads in the .sitemap XML files." type="BlogEngine.Core.Web.Controls.PageSiteMap, BlogEngine.Core"/>
<add name="SecuritySiteMap" description="Used for authenticated users." type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" securityTrimmingEnabled="true" siteMapFile="Web.sitemap" />
</providers>
</siteMap>

<httpModules>
<add name="WwwSubDomainModule" type="BlogEngine.Core.Web.HttpModules.WwwSubDomainModule, BlogEngine.Core"/>
<add name="UrlRewrite" type="BlogEngine.Core.Web.HttpModules.UrlRewrite, BlogEngine.Core"/>
<add name="CompressionModule" type="BlogEngine.Core.Web.HttpModules.CompressionModule, BlogEngine.Core"/>
<add name="ReferrerModule" type="BlogEngine.Core.Web.HttpModules.ReferrerModule, BlogEngine.Core"/>
<!--The CleanPageModule below removes whitespace which makes the page load faster in IE. Enable at own risk -->
<!--<add name="CleanPageModule" type="BlogEngine.Core.Web.HttpModules.CleanPageModule, BlogEngine.Core"/>-->

<!--Remove the default ASP.NET modules we don't need-->
<remove name="PassportAuthentication" />
<remove name="Profile" />
<remove name="AnonymousIdentification" />
</httpModules>

<httpHandlers>
<remove verb="" path=".asmx"/>
<remove verb="" path="/privateAssets/."/>
<remove verb="" path=".gif" />
<remove verb="" path=".jpg" />
<remove verb="" path=".js" />
<remove verb="" path=".jpeg"/>
<remove verb="" path=".jpe" />
<remove verb="" path=".css" />
<remove verb="" path=".doc" />
<remove verb="" path=".pdf" />
<remove verb="" path=".xls" />
<remove verb="" path=".ppt" />
<remove verb="" path=".txt" />
<remove verb="" path=".xml" />
<remove verb="" path=".xslt" />
<remove verb="" path=".xsd" />
<remove verb="" path=".cab" />
<remove verb="" path=".ocx" />
<remove verb="" path=".ico" />
<remove verb="" path=".png" />
<remove verb="" path="/*.htm" />
<remove verb="" path=".html" />
<remove verb="" path="" />
<remove verb="" path="/WorkArea/showcontent*.aspx" />
<add verb="*" path="file.axd" type="BlogEngine.Core.Web.HttpHandlers.FileHandler, BlogEngine.Core" validate="false"/>
<add verb="*" path="image.axd" type="BlogEngine.Core.Web.HttpHandlers.ImageHandler, BlogEngine.Core" validate="false"/>
<add verb="*" path="syndication.axd" type="BlogEngine.Core.Web.HttpHandlers.SyndicationHandler, BlogEngine.Core" validate="false"/>
<add verb="*" path="sitemap.axd" type="BlogEngine.Core.Web.HttpHandlers.SiteMap, BlogEngine.Core" validate="false"/>
<add verb="*" path="trackback.axd" type="BlogEngine.Core.Web.HttpHandlers.TrackbackHandler, BlogEngine.Core" validate="false"/>
<add verb="*" path="pingback.axd" type="BlogEngine.Core.Web.HttpHandlers.PingbackHandler, BlogEngine.Core" validate="false"/>
<add verb="*" path="opensearch.axd" type="BlogEngine.Core.Web.HttpHandlers.OpenSearchHandler, BlogEngine.Core" validate="false"/>
<add verb="*" path="metaweblog.axd" type="BlogEngine.Core.API.MetaWeblog.MetaWeblogHandler, BlogEngine.Core" validate="false"/>
<add verb="*" path="rsd.axd" type="BlogEngine.Core.Web.HttpHandlers.RsdHandler, BlogEngine.Core" validate="false"/>
<add verb="*" path="css.axd" type="BlogEngine.Core.Web.HttpHandlers.CssHandler, BlogEngine.Core" validate="false"/>
<add verb="*" path="js.axd" type="BlogEngine.Core.Web.HttpHandlers.JavaScriptHandler, BlogEngine.Core" validate="false"/>
<add verb="*" path="rating.axd" type="BlogEngine.Core.Web.HttpHandlers.RatingHandler, BlogEngine.Core" validate="false"/>
<add verb="*" path="opml.axd" type="BlogEngine.Core.Web.HttpHandlers.OpmlHandler, BlogEngine.Core" validate="false"/>
<add verb="*" path="monster.axd" type="BlogEngine.Core.Web.HttpHandlers.MonsterHandler, BlogEngine.Core" validate="false"/>
<add verb="*" path="blogml.axd" type="BlogEngine.Core.Web.HttpHandlers.BlogMLExportHandler, BlogEngine.Core" validate="false"/>
</httpHandlers>

</system.web>
</configuration>
May 20, 2009 at 7:26 PM

Has anyone solved this issue, I am having the same problem.

 

Thanks for your time,

from a .net (not quite n00b) newbie

:D

Coordinator
May 20, 2009 at 7:53 PM

What error?  This error:

"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."

It's a straight forward error.  If you're running the site through IIS, you need to have the blog folder marked as an application in IIS.  If you're running it through VS, you need to open the blog folder in VS (File -> Open -> Website -> choose Blog folder).  If you open a parent folder in VS, you'll get this error.

May 20, 2009 at 9:22 PM
Yes that error.  I am trying to add a directory "/blog" to a website I am building.  Blog Engine lives in "~/blog/".  The website has a web.config in the root.
 
Is there anyway for me to run the "main" site, click on a blog link, and view the blog?  The blog is not meant to be the whole site, but a portion of it.  Due to integration (in otherwords, I want to be able to get into the Database for the blog, and display data elsewhere), I really need to test the whole site.  Can I not do this?  If not, why?  I really need this to run in debug mode. (default start page of /default.aspx, and hit F5).
Even if I set up a local IIS, point localhost  at a local directory and try to do a publish, the "/blog" directory will not build.
 
Thanks in advance for the help.

Coordinator
May 20, 2009 at 11:01 PM
Edited May 20, 2009 at 11:03 PM

Here's what I believe you can do.

 - Move the blog subfolder outside its current parent folder.  The parent folder and blog folder can be siblings or the blog folder can be anywhere else on your computer.
 
 - In IIS, create a website or web application for your main site (if you haven't already).
 
 - In IIS, make the blog folder a sub-application under the main site.  If you're using IIS7, right-click on the main site/app, and select "Add Application", point to the folder where the blog is.  You can call this application "blog".  If you're using IIS 5.1 (WinXP) and probably IIS 6 too, right-click on the main site/app, and select New -> Virtual Directory.  In the Wizard, call the new directory "blog", and point to the physical location.  You should then see the blog sub-application under the main site/app.
 
If you already have your main site setup in VS to use IIS, then no change in VS is needed for the main site.  Otherwise, if you right-click on the website in Solution Explorer, select Property Pages and go to the Start Options section, in the 'Server' section, select the 'Use custom server' radio button and enter the IIS URL in.  E.g. http://localhost/mainsite/ or just http://localhost (depending on how it's setup in IIS).

Then close the solution and open up the blog folder in VS (File -> Open -> Website).  Like the previous step, right-click on the website in Solution Explorer, select Property Pages and go to the Start Options section, in the 'Server' section, select the 'Use custom server' radio button and enter the IIS URL for the blog application.  E.g. http://localhost/mainsite/blog/ or just http://localhost/blog/ (depending on how it's setup in IIS).

You can then run either project in VS with a normal F5.  Debugging should work too.  You can add both websites as separate websites in a single VS Solution file, or you can close a solution in VS and open the other solution (the other website) in VS to work with the other solution.

IIS supports sub-applications, but VS doesn't understand sub-applications.  This should workaround this VS limitation.