IIS Application Configuration Error - asp.net

Error Message: "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."
This is the error I get with an application I build in Visual Studios Express 2012 (for Web). It is using .Net Framework 4.5 which I recently installed onto the computer. I first created a Virtual Directory and got this error. So, I looked up possible solutions and have done the following:
I cleaned the application in VS. No change.
I deleted the obj folder. No change.
I converted the Virtual Directory to an Application. No change.
So far, these are the only solutions I have managed to find and none of them worked for me. Could anyone give me some other ideas?

This happens when a web.config file defines a value for which the parent has already defined and children are not allowed to define themselves. For example, you could have in your application's web.config an authentication value of 'mode="Windows"' but the parent has already defined the value as 'Forms'. Comment out all web.config values except for your appSettings and connectionStrings and see if the site works. If it does, start uncommenting the lines you've commented out one by one to figure out which section is causing the problem.
Edit for comment
Your IIS setup is the problem. You need to double check where the application directory is and whether an application (not virtual directory) has been properly set up in IIS. IIS 7 now has websites, applications, and virtual directories. You have a directory that is under a site but is not set up properly as an application. And just creating a virtual directory out of the site's directory does not make it run in its own process space, ala websites and applications.

Related

Already deployed asp.net web application wont run in different machine

I am trying to run an already-deployed ASP.NET web application on a different machine, but I am getting a machine-to-application error. I am a beginner to ASP so please help me out with this.
This is the error which I get:
"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."
This is an error that is received when you deploy the application to a folder that is not marked as an application in IIS and you have a configuration setting that only works at the root application level. You don't have to do anything with the application, this should completely be an IIS setting. Right-click on the folder in IIS and select Convert to Application and choose the Application Pool appropriate for your application's framework version.
Turns out that the VS was complaining about a configuration section within the web.config file in the Backup folder application...just remove the backup folder so it doesn't have a web.config file under the Virtual directory that your ASP.NET application is running in.
Hope this will help you,
for more detail go through
http://forums.asp.net/t/1031775.aspx?Configuration+Error+allowDefinition+MachineToApplication+beyond+application+level

Errors deploying ASP.NET project to remote host

I have a asp.net project that is working very well on my machine (on localhost) ...
But when I put it on a real host (put it online) a faced a problem ....
I got this error :
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'AWP_Project.Default'.
Source Error:
Line 1: <%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AWP_Project.Default" %>
Line 2:
Line 3:
there is a problem in the first line of this page (and every other page when I try it)
note : my project name is AWP_Project
can anybody helps my please ???
A common "pitfall" when it comes to moving your (compiled or not) project to your web host from your local machine is that the web host may not have the same configuration as your project/local/development machine.
make sure you have all the assemblies in your /bin folder
if you somehow created assemblies (dlls) for each file, then make sure all of them are copied to your web host
Your web host will (likely) have different security settings than your own machine while you are debugging. You're working on full trust locally/in Visual Studio, while most, if not all web hosts will likely be using medium trust. So a good rule of thumb while developing in Visual Studio is to set your web.config to medium trust to avoid pitfalls "at the last moment" - particularly if you don't have a dedicated machine at your web host.
just because you have .Net 4 on your machine, doesn't automatically mean your web host has it. You can bin deploy the assemblies you need - in VS 2010 right click your project and select "Add Deployable Dependencies" - this will add all the necessary dlls you need in your /bin folder. Yes, you will likely not need all of them, but unless/until you're fairly comfortable in choosing which one should or shouldn't be deployed, you'll have to trust Visual Studio....
I'm hesitant to add this, but still - ask your web host what verison of ASP.Net/.Net Framework they support. It sounds funny but trust me, I'm hosted on one of the largest and well known/trusted web hosts out there and to this day, I have to contact support (but their support is "fanatical" - clue to who it is) to have my web site/s set to ASP.Net 4 (they support it but an extra manual config is needed by their personnel).
hth
Try to create a virtual directory/website on your remote host and upload to root of that virtual directory via copy web site menu or publish website.
Often, your app doesn't work if you upload to a folder only. you should copy to the root of virtual directory or create a virtual dir that refer to your folder.
Please check this url link: Cannot use asp classes in app code/bin/web service
Hope this help

Windows Server 2003 IIS Renders ASP.NET 4.0 pages as blank

I have a web project which works fine on my local development machine.
I copied the project to our UAT server, setup a virtual directory pointing to the project and configured it to run on .NET Framework 4.0. I even added the Default.aspx page to the Documents tab. I configured Directory Security to use Windows Authentication.
When i try to access any web page within this application, IIS responds with a blank page. I looked through the event logs and don't see any errors anywhere.
Can someone please help me understand what's going on and how to remedy this?
Thanks in advance!
If you're just seeing a white page with no errors in the event log, it sounds like it could be a problem with the application rather than the hosting environment.
However, there are a few things you could try to doing to troubleshoot this.
Check folder permissions. Try allowing "Everyone" access on your webroot folder and see if that makes any difference.
Confirm that the IIS path is set up correctly but putting a text file in your webroot folder, and then browsing to it and verifying that it's contents are displayed.
Create a basic test.aspx page without any script, just a "Hello World" bit of text, and try browsing to it. Confirm that it displays the correct content.
Edit web.config and turn off custom errors
Try re-registering the ASP.NET extensions with IIS using aspnet_iis (details here)
Hopefully, one of these tests will be able to give you some kind of detailed error message or more insight into the cause of the problem.
For IIS 6.0 on Windows Server 2003, after the install of .NET Framework 4.0, the process of creating Web Sites or Virtual Directories that run under .NET Framework 4.0 is as follows:
Create a new application pool.
Applications running under different
frameworks can't be hosted in the
same application pool, i.e. create
an application pool perf framework.
Next, if you are creating a local
intranet site or virtual directory,
ensure that you don't have "dots" in
the application name. Browsers
confuse the dots to be external web
sites, forcing them to run under
internet zone as appose to the
intranet zone.
Once you create your web site or
virtual directory, make sure that it
runs under an application pool
dedicated for .NET 4.0 applications.
Ensure that when creating your
website or virtual directory, you
click on the ASP.NET tab and select
version 4.0 from the drop down.
Then you may configure as per
normal, with any other additional
settings you may require.
Hope this helps someone experiencing similar issues. Took a while to figure out.

Error: allowDefinition='MachineToApplication' beyond application level

I have downloaded the online project in ASP.Net. While running application I get an 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.
What changes should i make in web.config or elsewhere to make this work?
I've just encountered this "delight". It seems to present itself just after I've published a web application in release mode.
The only way to consistently get round the issue that I've found is to follow this checklist:
Clean solution whilst your solution is configured in Release mode.
Clean solution whilst your solution is configured in Debug mode.
Build whilst your solution is configured in Debug mode.
Just come across this post and that was happening to me.
Just Clean the project and the error goes away. (must be a VS2010 bug)
I have just had this problem when building a second version of my website. It didn't happen when I built it the first time.
I have just deleted the bin and obj folders, run a Clean Solution and built it again, this time without any problem.
None. You need to set up the directory you've placed the website as a web application within IIS.
This error occurs when you attempt to open a project as a website. The easiest way to determine if you've created a website or a project is to check your solution folder (i.e. where you saved your code) and see if you have a *.sln file in the root directory, if you do then you've created a project.
Just to add, I encountered this error just now when I attempted to open a project I created a while back by selecting "File", "Open Website" from the Visual Studio menus whereas I should have selected "File", "Open Project" instead. I facepalmed as soon as I realised :)
If you have MVC project with enabled views build, one of the solution is to delete obj folder before build. Add to project file:
<Target Name="BeforeBuild">
<!-- Remove obj folder -->
<RemoveDir Directories="$(BaseIntermediateOutputPath)" />
<!-- Remove bin folder -->
<RemoveDir Directories="$(BaseOutputPath)" />
</Target>
Here is article: How to remove bin and/or obj folder before the build or deploy
In Visual Studio 2013 I struggled with this for a while and it is pretty much easy to solve just follow what the exceptions says "virtual directory not being configured as an application in IIS"
In my case I had WebService planted inside IIS website so
I opened the website in IIS manager
right clicked the WCF folder
clicked Convert to Application
and then submitted with Ok
WCF is back and running.
The error suggests that the code you are using is expecting a virtual directory to be setup on IIS.
Look up the documentation and add the required virtual directory. It should be a directory that has a web.config in it (not the root directory).
A recent web.config change may be in the wrong web.config file.
A <machineKey...> property had been added to Views/web.config. No matter how many Cleans and Rebuilds the error remained. The fix was to move the property into the root /web.config.
if you ever encounter 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
SOLUTION
I had the same issue with VS 2012.
I resolved this by
Unload your current project
edit your .csproj
Find this <MvcBuildViews>false</MvcBuildViews>
Instead of false change the value to true
Load again your project and you should not have any more this error
If you do have then one solution is to delete the content of the obj folder in the project generated by compiler.
In my case, the problem appeared only after I published the project to the subdirectory. Because of my lack of knowledge, I have placed my web_publish subdirectory inside the web_project directory.
It is clear that the web_publish contains also the same Web.configs that the project contains. However, the web_project does not know that my web_publish should be avoided when searching Web.configs in the nested subdirectories. This way, the Web.configs were duplicated and the error appeared.
The solution was to place my web_publish somewhere else.
In my case there was a "Backup" folder which contained another copy of the whole website in there. This meant another web.config and so the build failed with this error. I deleted the "Backup" folder, did a Clean solution on the Debug and Release builds, and the error disappeared.
In my case,
Solution contains 6 projects, 1 main and 5 sub directories. all the sub directories having web.config.
When running any page within sub directories, I was getting same error.
I removed this line from web.config,
<authentication mode="Windows"/>
that worked for me.
Clean your project
Remove the /obj folder (probably using publish and deploy? - there is a bug in it)
My problem was I had accidentally published my webservice to a pre-completed location on a fresh install of VS2010.
I had published to a folder called PreCompiledWeb, and the presence of the web.config I suspect messed it up.
I simply nuked the folder, and refreshed the project.
When double-clicking this error - it took me to that erroneous web.config file, which tipped me off.
It may be the version problem like you download the project of .Net framework 2.0 and want to open it into the VS2008 then you will need to upgrade to the latest version and VS will create the Backup of the folder in same root directory.You will get the answer here.
I had this error when building the solution with Web Deployment Project created into my solution. I resolve the error by deleting the folder where Web Deployment Project is built to. This folder is specified in "Project Folder" attribute of WDP properties
Delete bin and obj folders. Then rebuild the solution.
Apparently there were two web.config files in my solution. I am using MVC4 and there was another config file under Views and i was making the change in the wrong file. Fixed there helped me.
But you can always change the default redirect/route in the global.asax file.
Probably you have a sub asp.net project folder within the project folder which is not configured as virtual directory. Setup the project to run in IIS.
I added to my website publish script. At the end, delete the obj folder from your website folder.
I've this problem more frequent if "true" is enabled in the project file.
Set false
As Jonny says:
Clean solution whilst your solution is configured in Release mode.
Clean solution whilst your solution is configured in Debug mode.
Build whilst your solution is configured in Debug mode.
I had a project that I didn't want to be a web application I wanted it to be a folder. The answer was to delete the web.config file altogether. It only belongs in the root of an application.
If you face this problem while publishing your website or application on some server, the simple solution I used is to convert folder which contains files to web application.
I've got the same problem in VS 2013 after publishing my project in debug mode. The problem has been solved by removing obj/ files
I have a website project.
In my case I had moved the solution file to another path and that cause the problem. I restored it to the previous location and the problem went out.
For any one still looking, my solution was to delete both the bin and obj folders and restart visual studio seems to fix it.
Via Visual Studio, I had published a WCF Service via FTP, to an external server. It worked fine locally, and when publishing to an internal server, but not to the external. The solution was to publish without providing a Site Path (in other words, publish directly to the root of the virtual directory).
I'm not sure why it worked, since I had already tried moving the files to the root via an external FTP Client - among many other attempts, including all listed here. Maybe it was something with the publish profile, like it was for FabianVal. But I'm not in the mood of testing anymore at this point, since I'm in a hurry to get up to speed after all the days wasted on this problem.
tip 1: clean & then rebuild.
tip 2: just close VS and open again.
tip 3: the downloaded project may be inside another sub folder... open the folder which has you .net files.
c:/demo1/demo/
(all files)
You should have to open demo from vs... not demo1.
I tried every solution above, but none of them worked for my problem. (I'm sure there are 1000 solutions to this problem) For my scenario, I was attempting to publish my WCF web service that I had in test into production.
However, I failed to realize that in production we are HTTPS only, meaning we redirect everything to HTTPS. As it turns out, I was pointing to the service via HTTP instead of HTTPS, thus causing the error. The solution in this scenario was to simply to change the address protocol to HTTPS rather than HTTP.
I hope that helps some poor soul out there trying to figure out this problem.

ASP.NET hostingEnvironment / shadowCopyBinAssemblies

Today I stumpled upon the shadowCopyBinAssemblies option in the hostingEnvironment tag.
Appearently this attribute it is a web.config (system.web) configuration Boolean option indicating whether the assemblies of an application in the Bin directory are shadow copied to the application's ASP.NET Temporary Files directory.
<hostingEnvironment shadowCopyBinAssemblies="false" />
A colleague had to enable this setting because (only) on his development machine he frequently got that ASP.NET error in the web browser:
Cannot create shadow copy assembly file dll when that file already exists.
compiling a specific web project in Visual Studio 2008 and openining a page.
So now my question: can I preserve this setting in a production environment or could it harm performance and/or create other issues?
Thanks!
I get this error from time to time, and usually doing Clean Solution followed by Rebuild Solution takes care of the problem. If this works for your colleague, then there's no need to play with the setting (especially in production).

Resources