Error allowDefinition='MachineToApplication' beyond application level in asp.net - c#

recently while working on asp.net application, i got below 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 am sure the previous day it was working absolutely fine, however i guess this error occurs usually because of multiple web.config files, but i checked in my project, whole project contains single web.config files, can anyone please tell me what could be the reason for this error.

As the error suggests, You need to set up the directory you've placed the website in as a web application within IIS.

Thanks Nawaaz, i got the resolution, actually that was because i was opening website (using file-->open-->website) and not the solution, so i opened the solution and cleaned the solution and build it, and worked properly, thanks a lot for taking time to revert.

Related

ASP.NET Core or ASP.NET Core MVC solution fails to run, IIS Express throws HTTP Error 500.30 - ASP.NET Core app failed to start

I've been having this error happen on even the simplest "Hello world" ASP.NET Core web app in Visual Studio. (Win 10 Pro, IIS Express, VS 2019 CE.) Steps to reproduce:
Create a new ASP.NET Core or ASP.NET Core MVC solution in Visual Studio 2019. Select the options to generate the scaffolding code for the basic "hello world" app. It doesn't matter whether you target .NET Core 2.1, .NET Core 3.1, or .NET 5.0, the result is the same in the scenarios I attempted.
The project and solution loads and the source code is visible and looks correct. Press F5 to run it. App compiles but does not run.
Expected behavior: the "hello world" app loads.
Actual behavior: shows this error message in the web browser:
"HTTP Error 500.30 - ASP.NET Core app failed to start" (and some
troubleshooting steps, then) "For more information visit:
https://go.microsoft.com/fwlink/?LinkID=2028265".
Go ahead and follow that link, then use those resources to double-check that you have all the needed packages and your IIS is configured properly. Mine was all looking good on my machine, but still I was getting this error. I even tried reinstalling VS, the hosting bundle, IIS, etc. but to no avail.
NOTE: This issue is a little different than the "500.32 ANCM Failed To
Load DLL" or the "500.36 ANCM Out-Of-Process Handler Load Failure"
errors, but I also encountered those during my troubleshooting, so I'm
mentioning them here in case it helps someone else.
NOTE ALSO: you do not necessarily have a corrupted ASP.NET Core
Module as this documentation would have you believe.
Check the event logs, you'll find some errors in there, but those are not particularly helpful in diagnosing the issue in this case. In my case, it just says
"Application '/LM/W3SVC/2/ROOT' with physical root 'H:\Repo
(R;)\sandbox\AspNetCoreWebApp001\AspNetCoreWebApp001' failed to load
coreclr. Exception message: CLR worker thread exited prematurely"
and
"Application has exited from Program.Main with exit code =
'-2147450743'. Please check the stderr logs for more information."
They show IIS Express AspNetCore Module as the source. Vendor docs were not terribly helpful on this scenario.
Double check to be sure you've got your IIS configration correct, and that you have the right packages installed, including the .NET Core Hosting Bundle. If you don't, or if you're trying different configurations like I was during troubleshooting, then you might see the ANCM errors mentioned above. If you get those errors, here are two links that can help. I read those links and checked my machine carefully, multiple times. In my case, this was all correct and complete, and I still had the error.
Fight with the computer some more, call it some bad names, reinstall Visual Studio for the 3rd time, verify IIS settings for the 8th time, ask your friends for help, check SO and Google yet again. The simple hello world app still won't run, same error. It runs on another machine, so there's nothing wrong with the code itself.
This was the solution that eventually fixed it on my machine: I moved the solution to a different folder. HUH??? How could that possibly fix this issue, I asked. After more head-banging, I eventually arrived at the root cause: a semicolon in the path. Yup. In my case, I had been storing the solution in a directory called "H:\Repo (R;)". It turns out, even though the ; character is allowed by the Windows OS, the .NET CLR does not like it at all and doesn't know what to do with it. So it generates the unhelpful error message.
Try it out. Rename the folder of your "this should be working" solution to remove the semicolons, close and reopen the solution in VS, press F5 and watch it run. Or go to a working solution and rename the folder to contain a semicolon and watch it break the CLR.
I was curious whether any other special characters in a folder name would cause an issue, so I checked them all (on folders, not on filenames, but I'd expect a similar result for filenames too). Here's my exhaustive test:
Windows disallows these in folder names:
\/:*?"<>|
The solution will load and run when the path contains any of these special characters:
`~-_+=',.()[]{}!##$%&
However, having any of these characters in the path, while being allowed by Windows, will cause issues in the CLR or in Visual Studio:
; Causes "HTTP Error 500.30 - ASP.NET Core app failed to start"
^ VS fails to load the solution & shows error message as follows:
"The following files were specified on the command line: <the .sln file>
These files could not be found and will not be loaded."
A totally empty instance of VS loads instead.
I also tried creating a new "hello world" console app in VS under a folder containing a semicolon in the name, and guess what? That also fails to run. Though in that case, obviously there is no HTTP error from IIS. Instead, it says
"Failed to create CoreCLR, HRESULT: 0x80070057"
and throws a process exit code. Once again, it's the result of having a semicolon in the path, because removing that semicolon from the path and reloading the solution in VS allows it to run correctly. So the semicolon issue seems to be originating from the CLR and therefore is unrelated to IIS.
Here are some related posts regarding the root cause, which is not readily apparent for web apps running on IIS Express:
Failed to create CoreCLR, HRESULT: 0x80070057
https://github.com/dotnet/sdk/issues/13954
So, kudos to those authors for those posts which were very helpful in the RCA.
One would think that the special characters allowed by the OS would also be fair game to use in the path to your Visual Studio code. Oh well. Lesson learned.

IIS Web API cannot be accessed [duplicate]

I want to upload my own asp.net website on IIS with IIS Manager. But when I do this, I get the following error
HTTP Error 500.19 - Internal Server Error The requested page cannot be
accessed because the related configuration data for the page is
invalid
Module IIS Web Core
Notification Unknown
Handler Not yet determined
Error Code 0x80070005
Config Error Cannot read configuration file due to insufficient permissions
Config File \\?\C:\Users\Yasso\Documents\Visual Studio 2008\WebSites\WebSite5\web.config
I searched many times for a solution for this error, but none of the solutions solved the error.
I have a problem with my IUSR account. I can't see this account in the "group or user names" in the properties of the web.config.
What is the problem?
This can also happen if the site is configured to use the IIS URL Rewrite module but it is not installed.
Finally, I got the solution for my problem. The ASP.net account did not appear in the IIS manager, because I didn’t check its checkbox in IIS. To do this in Windows 7 follow the steps:
Open control panel
Click on “program” link (not uninstall programs)
Click “turn windows features on/off” link
Locate “Internet Information services IIS” in the pop up window and expand its node
Expand the “World Wide Web Service” node
Expand “Application Development Features” node
Check the check box of “ASP.NET”
Then click ok button
Now, you will see the ASP.net account on the IIS manager and by default you will see the IIS account. Now, you should move your ASP.net website from “my document” to another place where the IIS have permission to access it (i.e. to another partition on your computer). Now, browse your website from the IIS manager and it should work.
Thanks a lot for Jeff Turner for the solution.
The message is saying that your configuration file is corrupt in some way. However it also says that it can't actually access the config file. So I'd ignore the original message about corruption/lack of validity as this is most likely just the effect of not being able to read the file due to a lack of authorization.
The reason it cannot read the config file is because the process running your web app does not have permission to access the file/directory. So you need to give the process running your web app those permissions.
The access rights should be fairly straightforward, i.e. at least Read, and, depending on your app, maybe Write.
Above, you mention IUSR etc. not being in the properties for web.config. If by that you mean that IUSR is not listed in the security tab of the file then it's a good thing. One doesn't want to give IUSR any kind of permission to web.config. The role IUSR is an anonymous internet user.
The file web.config should only be accessible through your application.
The problem is you haven't said which OS and IIS version you are using so it's difficult to advise which steps to take.
I.e. in IIS 7.5, the error message you're quoting is likely to occur due to your ApplicationPoolIdentity not being assigned the permissions. Your web application belongs to an application pool and so you need to give the permissions to the OS account that your web application's application pool runs under. Often this is something like NetworkService but you may have customized it to run under a purpose made account. Without more info it's difficult to help you.
I was having the same problem, here is the solution that worked for me.
IIS Manager
Right clicked on that Website
Edit Permissions
Added user 'IIS_IUSRS' from Security tab
Gave full permissions to User 'IIS_IUSRS'
Set the Application Pool's Identity to 'ApplicationPoolIdentity'
For Visual Studio (VS) developers:
As hinted at by Harvey Darvey, Savage, and Snives, your Application Host Configuration may be pointing to the wrong application physical path. Search for virtualDirectory within /.vs/config/applicationhost.config to change the physicalPath if it is incorrect.
Make sure the physicalPath is correct:
Just to chip in, I received the same kind of error and my problem was quite simple: I was missing the .NET Core Hosting Bundle. Once I installed the tool and restarted the server, it was fine.
You can find the manual to host asp.net core on windows here: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.2
To resolve this, make sure you installed the hosting bundle.
https://dotnet.microsoft.com/download/dotnet-core/3.1
Facepalm alert:
You will also get this error if the path to the config file is wrong. Double-check it to make sure the physical path is entered correctly in IIS.
You need to assign permissions for IIS_IUSRS on the local machine (but you don't have to assign for IUSR, in fact it will work even if you explicitly deny permissions).
To assign permissions, just right click on the folder and on the security tab make sure to grant the correct permissions, and if the user is not listed then click "ADD", and enter IIS_IUSRS (and make sure that under "domain" the local computer is selected, or enter in the name field YourLocalComputerName\IIS_IUSRS), and then you are good to go.
If you want you can instead of assigning permissions to the IIS_IUSRS group, you can instead assign to the app pool which should in general be "IIS APPPOOL\ app pool name".
The same thing happened with me , Try checking this by double clicking on the Connection strings on the right pane of IIS 7 when you select a website.
It will give you an error (that there is some problem with web config file), because you have used URL rewrite rules and the respective component is not installed.
Install “Microsoft URL Rewrite Module 2.0 for IIS 7” and this should fix your problem
Install ASP.NET Core module
Download the installer using the following link:
https://www.microsoft.com/net/permalink/dotnetcore-current-windows-runtime-bundle-installer
Nothing here worked for me, I found this command in another SO answer though and it solved my problem. Just start command prompt as an administrator and run this command:
run->cmd
run "c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i"
Credit: User Vicxx
Ehm. I had moved my site/files to a different folder. Without changing the path in the IIS website.
You may all laugh now.
I do these steps to solve this problem in
Windows Server 2012, IIS 8.5. Should work for other versions too.
Go to server manager, click add roles and features
In the roles section choose: Web Server
Under Security sub-section choose everything (I excluded digest, IP restrictions and URL authorization as we don't use them)
Under Application Development choose .NET Extensibility 4.5, ASP.NET 4.5 and both ISAPI entries
In the features section choose: NET 3.5, .NET 4.5, ASP.NET 4.5
In the web server section choose: Web Server (all), Management Tools (IIS Management Console and Management Service), Windows
Make sure you have the application pool set to the correct version of the framework. You'll also need to make sure your aspnet, IIS_IUSRS, or IUSR users have read access to the application's directory.
Try installing the 'Application Development' sub component of IIS as mentioned in this SO
Click "Start button" in the search box, enter "Turn windows features
on or off"
in the features window, Click: "Internet Information
Services"
Click: "World Wide Web Services"
Click: "Application
Development Features"
Check (enable) the features. I checked all but
CGI.
One other possibility that fixed this problem for me:
IIS -> Edit Permissions -> Security Tab -> Give "Users" appropriate permissions (or IIS_IUSRS, depending on your setup)
This also happened to me when I had a default document of the same name (like index.aspx) specified in both my web.config file AND my IIS website. I ended up removing the entry from the IIS website and kept the web.config entry like below:
<system.webServer>
<defaultDocument>
<files>
<add value="index.aspx" />
</files>
</defaultDocument>...
Sometimes this message has can be missing components in your IIS environment e.g. a particular framework, or an IIS feature like dynamic compression, rather than permissions to web.config.
If this is the case, a solution can be to install and use the Microsoft Platform Installer and install those missing components - you might have to take a stab at what exactly is missing because the error log and message don't tell you.
Actually, any missing module can lead to this problem. In my case, it was CORS Module. So read the web.config and seek for any addon module that you specified in it and check that it is installed, or install it otherwise. Unfortunately, the error message does not help finding the problem at all.
Pretty straight forward, IIS doesn't have access to your web.config. I'd start by taking the site out of your documents folder. Verify it has r/w permissions then as well.
You need to set permission for your Website folder or copy they to wwwroot folder :)
- If set permission, have 2 way:
+ Right click to Your Website folder
+ Or right click to Your Website in IIS
=> select Edit permission and Add a permission (IUSR - default iis user)
Good luck ;-)
You can get this error if you have a synax error or issue in your web.config file.
For me, it was a stray ampersand in a URL that I was using in the AppSettings.
In my case, it caused by application physical path point to a non-existent folder in IIS.
got this problem with mapped drives, IIS doesn't work with mapped drives. Just use the unmapped drive.
I had the issue as I copied my web.config file down from prod, changed everything not prod related except the Rewrite rules which were rewriting to httpS.
Removed those rules and ran fine.
I too had the similar issue and i fixed it by commenting some sections in web.config file.
The project was earlier built and deployed in .Net 2.0. After migrating to .Net 3.5, it started throwing the exception.
Resolutions:
If your configuration file contains "<sectionGroup name="system.web.extensions>", comment it and run as this section is already available under Machine.config.
On the IIS 7.5 error page you get click on 'View more Information' at the bottom of the page and in this case it will take you to the following Microsoft link:
http://support.microsoft.com/kb/942055
The 0x80070005 Error Code seems to be permissions related and following the steps in Resolution 2, Method 2 assigning the correct accounts with permissions on relevant folders should fix it - I spent 3 days looking for a solution until I came across it, worked straight after.
Explore the folder where your website is store and see you will get one extra folder "aspnet_client" delete that folder and it will work for you.
I tried this my problem is solved.
If it works for you please make it as answer so that some body else will also get solution.
None of this worked for me, but I finally have a solution which worked for me:
remove this line in web.config:
<compilation debug="true" targetFramework="4.5"/>
don't remove this line
<compilation debug="true"/>

ASP.NET file compiled, still not found

I have an asp.net (version 4) website, for which I made a copy of the default.aspx file to test an alternate design. Works perfectly on my dev PC (IIS 7.5 I think) but I get a "Page not found" error on the server.
The really strange thing is that when I wanted to troubleshoot this and renamed the file but forgot to change the CodeFile="default2.aspx.cs" in the first line of default2.aspx, I got an error saying that it couldn't compile. Which was correct, of course. But when I change that too so that it compiles, it goes back to the page not found error.
So if it can't be compiled, it's there.
If it compiles, it's not there.
What am I missing here?
PS. In the IIS logs I see 404s and sometimes 301s. I checked some explanations of 301 so I'd like to rule out the redirection as a possible solution. I don't redirect anywhere.
Still not sure where exactly the error was within FriendlyUrls, but getting rid of it solved the issue. So it was working on my dev machine with IIS 7.5, but IIS 6 on my rather old server seems to be incapable of handling FriendlyUrls. I don't really need that, so axed.

Unrecognized attribute disableAlternativeTemplates

Unfortunately I added a reference from another project in my solution instead of only copy pasting the libraries, So I think my assemblies got overridden.
Now I'm getting this error and I think its coming from umbraco.
Does anyone here had the same issue?
Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Unrecognized attribute 'disableAlternativeTemplates'. Note that attribute names are case-sensitive.
Source Error:
An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Source File: D:\WWW\website\config\umbracoSettings.config Line: 153
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34249
I've just had the exact same problem, but found if you overwrite the existing Umbraco Dlls, with the original ones, it fixed it
Ian
After a bunch of wasted hours, I also could not ever fix this issue, even after following Ian's advice above. I introduced this problem by upgrading a 7.1.6 site to 7.4.3. I did the upgrade incrementally, every 3 or 4 releases through Nuget, but the mistake I made was not running the site in between upgrades.
Running the site updates config files, and database values, etc and skipping that step was my kiss of death. So I guess this isn't really a solution, but more of how you can prevent it.
BTW - I went back and did the upgrades again (with bigger jumps between versions actually), ran the site after each upgrade, and it went perfectly.

ISS error CS0433: name collision

In our application we've run into an error numerous times where we get error CS0433, which complains about a name collison in two separate dlls. This is an ASP.NET app developed in C# using webforms. It always complained about A TimeLog page. Anyone have advice for resolving this error?
I found a link in the MSDN that describes this error.
To summarize, a naming conflict can happen between the file name of a page (TimeLogTab.aspx) and the class in the code behind (public class TimeLogTab).
The link recommends renaming one of them. I changed my class to Time_LogTab and the error went away.
The error can happen intermittently: I'm using "Publish Web Site" for a VS 2005 Web Application Project with "Delete all existing files prior to publish" and then XCOPY-Deploy to the target IIS folder (which won't delete existing files there). Today I ran into that error for the first time (no new .ascx/.aspx files since weeks), but simply recompiling and redeploying the same project solved the problem.
The only difference: For the 2nd time, I hit the page causing the problem first. Now I'm wondering whether the exact click order really matters or rather whether an arbitrary unlucky click order effectively can crash an ASP.NET site?

Categories