Andrew Stopford's Weblog

poobah

Sponsors

News

Articles

Family

Old Blogs

MSBuild bug and web projects pt2

More MSBuild pain, this time by way of the aspnet_compiler. Take a web project, some pages are nonsecure, some pages are secure and need forms authentication before you see them. Lets assume the project not in the IIS wwwroot directory either.

  • webpage1
  • secure\webpage2

In the web config you then assign forms authentication using

<authentication mode="Forms">

<forms name=".LOGIN" loginUrl="login.aspx" protection="All" timeout="60" path="secure"/>

</authentication>

If you compile this in VS2005 is fails with the following.

error ASPCONFIG: 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.

To fix this we make the secure directory a virtual directory in IIS, our project root is a virtual directory and so is the secure directory. You then compile this and it works, all good. Now more fun begins. If you build in MSBuild then we it gets the aspnet_compiler stage it fails with the same error. If you create one of the new fangled web projects it also fails when it reaches the aspnet_compiler stage. At this point no matter much you try it refuses to budge.

More interestingly if you look at VS2005 it hides the contents of secure and when you click them asks you if you want to add them to the project or view out side of the project, doing either option fails your build inside of VS2005,  thanks very much.

Update: check this for how to resolve this.

Comments

Hannes Preishuber said:

why you dont use location element in web.config?
# November 11, 2005 10:16 AM

BradleyB said:

You can use the aspnet_compiler to compile each vitrual directory individually. To do this pass the -m opition with the metabase path. Web Deployment projects support this same option but you'll need to open each vitraul directory as a seperate web and compile seperately.
# November 11, 2005 10:18 AM

BradleyB said:

I should qualify my last comment. I'm assuming that the vdir you created was a app root not just a vdir.
# November 11, 2005 11:12 AM