Web Deployment Project With Nested Applications - asp.net

I have a web application that I'm trying to create a Web Deployment Project for in Visual Studio 2008. My application also has a child web application. Both are web applications in IIS. I have added the Web Deployment Project so that I can automate the build process for this application. When I try to build the Web Deployment Project, I get the following error:
Error 639 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 the child web.config that the error is referring to. I've tried to find a solution on the web and while this seems to be a common error, neither of the two suggested solutions seems to fix my problem. The first solution is to make sure the application is an application in IIS which both of mine are. The second is to make sure there are no child web.configs anywhere in the solution. I have a child config but it is part of the child web application and cannot be eliminated.
Is there a way to get the Web Deployment Project to build with an application structure like this? If not, is there a way to automate building .Net web applications using MSBuild without a Web Deployment Project?

Found the answer here Specifically, if you have nested web applications, you need to enable the "Use IIS metabase path for source input" option in the Compliation section of the Web Deployment Project Properties. That will cause only the root application to be built. The default is for the Web Deployment Project to build all applications including children.

Related

Difficulty with Converting a WebSite to Web Application and Testing

This is not as straight forward as I had hoped.
I created a Web Site project on my development machine using the Visual Studio C# template for a WebSite Project. (Visual studio 2010 .net 4.0). The project name is C:\Nova5\WebSite3. It consists solely of:
the Bin subdirectory
Nova.svc file
web.config file
It has been tested to run correctly by:
Setting the website as the startup project, then
Run Debug-->Start Debugging
When tested, the NovaDataService information page is correctly displayed. It also correctly works when used through my client project.
I followed the recommended procedure described at
Walkthrough: Converting a Web Site Project to a Web Application Project in Visual Studio to covert the Web Site to a Web Application.
I now have the following problems and/or difficulties:
If I use the recommended procedure for testing the web site:
-- File | Open | Web Site
-- Build Web Site -- Start Debugging
I get the Error: The type 'Nova5WCFServiceLibrary.NovaDataService', provided as the Service attribute value in the ServiceHost directive, or provided in
the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
Since, I think, the WebSite does work, I skipped this error and moved on to the next part of the article. The next issue (?) is there is no App_Code file in the WebSite. Is this necessary? If it is necessary, how should I create it? Or do I need to create another WebSite project from its template just to have it?
I did not copy the Nova.svc nor the web.config from the WebSite to the Web Application as none of the references I read indicated to do so. Should I copy these files to the Web Application as well?
I now used the "Convert to Web Application" on the Web Application project and recompiled the solution. Everybody is happy. No errors reported. So how do I now test the Web Application project on my development machine (which also has the client application) ?
TIA

Publishing web apps and websites

I understand that references are stored in the project (vbproj) file for ASP.NET web applications and the Web.Config (http://msdn.microsoft.com/en-us/library/37e2zyhb%28v=vs.71%29.aspx) for websites.
I have recently converted a website into a web application. I notice now that the web application will publish (using the Publish option) even if the version information is incorrect in the Web.Config, then when accessing the web application through a browser I get an error.
I was unable to Publish a website if the version of an assembly in the Web.Config was incorrect.
I read that web applications are precompiled (before publish) whereas websites are compiled the first time the website is accessed through a browser.
Therefore, I believe what I have said should be the other way around i.e. I should be able to publish websites with an incorrect version in the Web.Config (because they are not compiled) and I should not be able to publish a web application.
What am I missing?
After some further research; I have discovered that ASP.NET web applications are built using MSBuild and ASP.NET websites are built using ASPnet_Compiler.
ASPnet_Compiler looks in the Web.Config for referenced assemblies (add assembly tag) at build time, whereas MSBuild looks in the project file (vbproj) at build time.
Web applications are deployed without the vbproj. I believe the project file is used for linking. Therefore at runtime a web application uses the information in the Web.Config to identify assemblies to look for in the local bin folder and then the GAC (for aspx pages only)i.e. namesapces still have to be manually imported into the code behind partial classes.
If anyone has any comments or better answer then please post.

Publishing a simple .NET web service yields IIS "It is an error to use a section registered as allowDefinition='MachineToApplication' ..."

This error has been reported elsewhere on stackoverflow, but none of the answers seem applicable to my situation.
I'm publishing a simple .NET web service (.asmx) and when I check the link in production, I'm met with the famous 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."
I've gone through the basics already, namely these three most popular hints:
1/ The directory has been created as an "Application" by right-clicking in IIS, et cetera. It's running in its own Application pool.
2/ There is no subdirectory containing any superfluous web.config files. It's just the one web.config.
3/ I've made sure that the namespace matches up with the web service definition, all that basic stuff. At any rate, the project runs fine locally and also runs fine when deployed to a test server. This is leading me to think 'permissions issue' on the prod server, but I'm at a loss since the normal IIS sites run fine.
So I guess what I'm asking is: is there a fourth-most-popular cause of this error that I"m missing?
Oh, the Web Service Application is set to allow web service calls for all versions of .NET installed on IIS.
Also, I'd be happy to leave this legacy approach behind and ditch the .asmx for WCF; however this is the piece of code I'm tasked with rolling out at present.
Thanks!
You need to make sure that your have the proper .net framework version selected in you Application Pool. You can check this by going into IIS manager and going to the Application Pools node. Right click on the application pool that is attached to the website that contains your service and select "Basic Settings" (this choice should be in the left hand column of the window too). Then from the drop down select the proper version of the framework. You might need to create a new application pool specifically for the child application if they need to operate on different versions of the framework.
If the parent site is using .net 4.0 your webservice is probably inheriting that or vice versa (2.0).
So in short, try switching your application pool to a different framework version and see if that clears it up.

Web Deploy and Asp.Net MVC 3 Error (Error to Use Section Beyond Application Level)

I've got a Visual Studio 2010 MVC 3 Project that I'm trying to deploy using the Web Deploy Publish option from within Visual Studio. Whenever I try to deploy I get the following 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.
When I google the above error I find that people say to either configure the virtual directory as an application, or to check for nested web.config files.
The site runs fine when I deploy the project to it manually, so I believe the site is configured properly. I don't have an application below the site tho, as the site itself is set up as the application.
Also while MVC projects do have nested web.config files (one in the root and one in the views folder) renaming the views web.config file didn't fix the error.
Have you tried deleting your complied code in the obj folder and re-compiling?

Do web.config transformations work during build/develop cycle not just during publish?

I'm trying to develop my first web application using Web.Config transformations.
Trying to run the app (building with the "Dev" build configuration)in the Asp.Net Debugging web server built into VS the site doesn't seem to work - the "Web.Dev.config" configuration doesn't appear to be seen by the application.
Is this to be expected? Is it only when deploying that the transformations happen?
Many thanks!
In any asp.net web site, only web.config is examined by the web server. web.dev.config will always be ignored (treated as nothing more than an unknown file). This is true regardless of whether running in Visual Studio or IIS.

Resources