Project load wrong web.config file - asp.net

I am using Visual Studio 2008 for .net project.
I have configured to use IIS as debug web server in the project property page.
I have two projects under c:\project, project1 and project 2. I can run project 1 with no problem. However when I try to run project 2 I got an error message, saying the web.config file is missing binary file from bin folder.
The server is trying to load the web.config file from project1 instead of project2.
I have checked the virtual path settings and project settings and could not find anything wrong.
Does anyone have such experience?
I could not find useful information on google.
Thanks,
Lewis

I found out that ON IIS manager, Default Web Site -> Basic Setting -> Physical path was set to perticular project.
I've changed it to C:\inetpub\wwwroot now when I run individual applicaiton they go and pick up correct config files

Make sure that project1 is an application whose base folder is the project1 directory and that project2 is an application whose base folder is the project2 directory. sounds like project1 is an application pointing to c:\project.

EDIT: How are your directories defined in IIS? If they are virtual directories, they must be defined as applications, otherwise it will try to use the root web.config.
Try this:
Shutting down all instance of Visual Studio
Stopping IIS (iisreset or restart the WWW service)
Delete everything in this directory: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
Open your projects back up

I also had this problem, it turned out I had mistakenly set up my website incorrectly in IIS.
I was pointing my default website to files for project 1, while a sub-application inside the default website was pointing to files for project 2, which was of course inheriting the web.config of project 1.

Related

the element 'buildProviders' cannot be defined below the application level

I have created an asp.net C# application developed in visual studio 2010, which is running without any error on my PC, but when i tried to run the same application on another computer with visual studio 2010, it gives following error,
The element 'buildProviders' cannot be defined below the application level.
Following article at http://forums.iis.net/t/1160248.aspx?The+element+buildProviders+cannot+be+defined+below+the+application+level+
You probably need to convert the virtual directory to application. I encountered this when deploying my app (using NancyFX).
You can open IIS Manager->Right-click the diretory of your web application->Click Convert to Application.
I faced this problem and i found out that somehow i had another version of my website within the subfolders of my webstie.
Meaning that my website is in a folder called "FrontEnd". Withing this folder there is a subforlder called backup that contains a backup of my website.
when i removed the backup folder, everything went ok.
If you recently upgraded your solution, check for the backup directory for crystal report within your solution. The backup directory can get created when you upgrade visual studio. To resolve this error, closed the solution. Went to the solution directory
and delete or move the backup directory to a different location outside of the solution directory. This solved the problem for me
You can fix this problem either defining the element in the web.config file of the root dir or setting Virtual Directory as APPLICATION in IIS.
For doing this with IIS 6.0, you first have to set the the directory in which your site is present as a Virtual Directory and then define this virtual directory as an Application.
All physical directories under Inetpub\Wwwroot are not considered applications until the following procedure is used:
Open IIS Manager.
Expand the Default Web Site node and look for the subdirectory that you want to designate as an application root.
Right-click the directory that you want to mark as an application root, and then click Properties.
On the Directory tab, in the Application Settings section, click Create.
In the Application name text box, type the name of the application, and then click OK.
The virtual directory is now an application root.
Maybe on oppening website you were selected upper project directory as website root
In my case, the issue was that the web.config inadvertently existed in a subfolder of the applications root folder. I had a "temp" subfolder, and I had placed a copy of the web.config there, unaware of the unintended side effects. The solution in my case was to remove the dup copy in the subfolder. Hth
(In my case name of project was repeating in directory )
The problem's solution is very simple: check its root directory in Solution Explorer. If there is a name folder within another name folder then this error will occur. Your web site contents should be very first after your web site name folder. In other words, contents should not display in another same name folder.

How to deploy 2 separate ASP.NET solutions under one IIS website

I am facing the issue how to deploy 2 separate ASP.NET solutions in one IIS website. This is how I plan to deploy. In the root website folder, I put one solution's published files. Then, I create another folder in that root folder and put another solution's published files.
When I run from IIS, only the contents from root folder works but those inside a folder doesn't work.
You can use sub folders (add virtual folder) in IIS.
Remember to set the folders "Convert to Web Application" so it works with dependent configuration context.
You need to set the subfolder as an IIS application in IIS Manager.

.Net 1.1 Web application is picking up web.config from root folder

I have a .Net 1.1 web application sitting in a folder called C:\inetpub\wwwroot\MyTestApp, where 'MyTestApp' is a virtual directory and is configured to be on ASP.Net version 1.1.4322 in IIS 5.1.
In the root directory (C:\inetpub\wwwroot) there is a web.config file for a .Net2.0 application, because the root folder contains some web pages written in .Net2.0.
Whenever I try to access 'MyTestApp' though I get an error...
Parser Error Message: Unrecognized configuration section 'connectionStrings'
Source File: c:\inetpub\wwwroot\web.config Line: 17
The .Net1.1 application in the MyTestApp folder is trying to access the web.config file in the root folder, and getting upset because it is on a different version. How can I tell the MyTestApp folder NOT to use the web.config file in the root folder, but instead just use the web.config in its own folder?
Is such a thing possible, or is nesting a .Net 1.1 application in a sub-folder under a .Net 2.0 application a no-no?
I think you need to configure your virtual directory for your 1.1 app as a "application" directory.
I am on IIS7, so I am providing this from memory!
If you right click it in IIS, and then click "Create Application" that should do the trick.
Web.config is always read based on proximity (closest to application first, up through folder structure, right up to Machine.config).
Hope this helps.
Edit
Checkout the guide on MSDN on creating Virtual Directories. It also touches on creating Applications.
You want to use the InheritInChildApplications setting in the root web.config and set this to false.

MSBuild error while compiling ASP.NET website

I get the following error when I try to compile an asp.net site using a custom build script.
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.
Although the description is in detail I do not understand what it means exactly. I have not configured IIS to host this website and I don't think I will be able to as I am running Vista Home Basic version. So the website cannot be built using custom scripts?Please reply as I want to test this feature.
I had this SAME EXACT problem and finally discovered a rogue Web.config was placed in my obj folder ... do yourself a favor and do a search in all the sub-directories for a web.config file. I deleted it and all was back to normal.
The rogue web.config file in the obj folder is most likely to be caused when you do a Publish Web Site. So just clean it up after you've done the publish.
if this happens after the virtual-directory is already created do the following:
right-click on web.config
properties
Build Action: Content
Copy to Output directory: Do not copy
if transformed (apply to all configurations)
properties
Build Action: None
Copy to Output directory: Do not copy
It is likely that your web.config file is placed in a directory that is not the root of the application. On most versions of IIS, you can convert any folder on your web site to an application root:
Open IIS and navigate to the appropriate folder
Right-click on the folder, select properties
Under Application Settings, and beside Application name, click Create
Apply and close
If this does not fix your problem, there may be another configuration error, either with IIS or your application.
In IIS, go to the folder that the app runs under, right click it, go to properties.
On the Directory tab, look for "Application settings". Click the create button.

How do I deploy a pre-compiled ASP.NET web application?

I have a web service implemented in ASP.NET 2.0 and have pre-compiled it using the aspnet_compiler.
I have no clue now how to deploy it to IIS, can someone point me in the right direction? I am using IIS 6.0 on a Windows Server 2003 machine.
I have placed the pre-compiled files into a virtual directory, when I access the service through the browser I get the following parser error message:
Parser Error Message: The page must have a
<%# webservice class="MyNamespace.MyClass" ... %> directive.
I then checked the .asmx file for said directive and the contents have been changed by the compiler to:
This is a marker file generated by the precompilation tool, and should not be deleted!
UPDATE: When I place the non-pre-compiled web app in the virtual directory it works fine, when I place the pre-compiled wen app in the virtual directory, I get the above errors.
Anyone have any ideas!?
You can either copy the contents of the output directory into the virtual directory on IIS and it should all just work. You will need to set up the App Pool and configure the virtual directory for ASP.NET just like a non-compiled website. Make sure you delete everything from the virtual directory (if there was a previous non-compiled site there).
Also you can use Web Deployment projects, which can serve as an input to an MSI installer.
The ASMX file contents are correct. Are you sure you have configured the Virtual Directory with an Application? Open the properties window by right clicking on the virtual directory and ensure the "Application Name" (on the "Virtual Directory" tab) is set and is editable.
Also have chosen the correct ASP.NET version on the tab? Check this on the "ASP.NET" tab of the properties window"
did you deploy the entire bin directory? You need to make sure the .COMPILED files created by aspnet_compiled are in your bin dir.

Resources