ASP.NET Error when trying to access page - asp.net

Im getting this odd error:
Any help would be great?
This is the error:
Server Error in '/Rugby' 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: 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.
Source Error:
Line 33:
Line 34:
Line 35: <roleManager enabled="true">
Line 36:
Line 37: <providers>
Source File: C:\Websites\ADHS\andyhollis.co.uk\rugby\admin\web.config
Line: 35
Show Additional Configuration Errors:
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.
(C:\Websites\ADHS\andyhollis.co.uk\rugby\admin\web.config
line 43)
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.
(C:\Websites\ADHS\andyhollis.co.uk\rugby\admin\web.config
line 67)
Version Information: Microsoft .NET
Framework Version:2.0.50727.3053;
ASP.NET Version:2.0.50727.3053

This sometimes happens when you have a Web.config in a subdirectory of the application's root.
Alternatively, you may need to go into the virtual directory and configure it correctly as an application (as noted by the error message).

It could be because you've accidentally uploaded a web.config to a non-root directory, or because the directory containing the web.config isn't configured as an application root.

As it says in the error message:
"This error can be caused by a virtual directory not being configured as an application in IIS."
Configure it as an application, and it will be fine.
IIS 5/6:
http://msdn.microsoft.com/en-us/library/zwk103ab.aspx
IIS 7:
http://mvolo.com/blogs/serverside/archive/2007/07/12/Creating-IIS7-sites_2C00_-applications_2C00_-and-virtual-directories.aspx

Basically, ASP.NET allows for hierarchical configuration files, starting from machine.config and numerous security based web.config files tucked away in the framework's config folder, and then going from the root of your web application down the subfolders.
However, some elements can only be overriden in the root web.config for each application. These include (but aren't limited to):
Authentication
Profile
RoleManagement
SecurityPolicy
SiteMap
The full list of web.configuration elements can be found under here, and each one has a section Element Information, with a subsection "Configurable locations". If it says "Virtual or physical directory–level Web.config" then you can have the element anywhere.
As this is presumably the admin screens of your application, you probably don't want to make the directory an application in it's own right - if you do you'd lose access to the main application below it, which isn't what you'd want, and you'll possibly also have to have a seperate /bin folder under there with the admin .dll in.
You would be better off configuring the RoleManagement in the root web.config of your site, (either at / or if Rugby is an application, then at /Rugby) and only having the elements you need to be different (e.g. the autherization element to lock out users) in the web.config in /Rugby/Admin.
For example, on one of my sites, the web config in the admin folder is just:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<authorization>
<!-- Allow users in role "Editor" -->
<allow roles="Editor" />
<!-- Block everyone else -->
<deny users="*" />
</authorization>
</system.web>
</configuration>

It looks like the error you didn't post has changed. Now it's "500 Internal Server Error". That usually means an unhandled exception. Look in the Windows Event Log to see what happened.

Related

Azure will not turn off custom errors

I'm in the process of migrating a client site to an Azure VM (stop gap until we rewrite to move to Azure Proper). The problem that I have is that there is a problem somewhere and I can't see what it is. When I run up the site I get the usual yellow screen of death...
Runtime Error
Description: 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.
Details: To enable the details of this specific error message to be
viewable on remote machines, please create a tag within
a "web.config" configuration file located in the root directory of the
current web application. This tag should then have its
"mode" attribute set to "Off".
Notes: The current error page you are seeing can be replaced by a
custom error page by modifying the "defaultRedirect" attribute of the
application's configuration tag to point to a custom
error page URL.
I have had this many times before in such situations, so I edited the web.config file to look like this...
<system.web>
<customErrors mode="Off" />
(other stuff)
</system.web>
... and the same message came up. I recycled the app pool and even restarted IIS but I still get the same message, it's as if the VM just doesn't care what I put in the config file.
I've added 'localhost' to the bindings so I can view it on the server directly and I get this instead...
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: An error occurred loading a configuration file:
Directory 'C:\inetpub\wwwroot\test.siansplan.com\config' does not
exist. Failed to start monitoring file changes.
Source Error:
[No relevant source lines]
Source File: C:\inetpub\wwwroot\test.siansplan.com\web.config Line:
0
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.0.30319.18447
Has anyone else come up against this before?
I'm at a loss what to do.
I found the answer to this one. The web.config file was referencing a child file which wasn't present. This is quite a gotcha if you can't use localhost based debugging.
Your system.web tag is not properly closed:
<system.web>
<customErrors mode="Off" />
(other stuff)
</ system.web>
Should be:
<system.web>
<customErrors mode="Off" />
(other stuff)
</system.web>

Solve error to use a section registered as allowDefinition='MachineToApplication' beyond application level without convert application in web site

Hi when a moved my project on line i obtain this error
Line 19: </assemblies>
Line 20: </compilation>
Line 21: <authentication mode="Forms">
Line 22: <forms loginUrl="~/user_login.aspx" name=".ASPXFORMSAUTHRECSHIELD" timeout="30" slidingExpiration="true" />
Line 23: </authentication>
Source File: d:\www\MW_qXnIPRqPq\shieldtrust.it\shield_trust\web.config Line: 21
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: 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 error I want to talk to my provider and configure the directory into a an application or is there another way?
For me, in the IIS, I had not converted the correct folder to Application. So while browsing, I was getting this error.
Once I converted the proper folder to application and hit browse, it worked properly.
There can be one of many possible reasons for this
You may have added a backup folder inside the main folder. If yes, Remove it.
Make sure that you have opened the correct root folder, in case you are running the project with Visual Studio
Make sure that you don't have any copy of web.config files kept in the project.
Hopefully it helps.
In case you are still experiencing the same problem, let me know :)

Server Error in '/' Application. ASP.NET

Greeting,
I developed a website using ASP.Net 3.5 and C#. It is working good with Visual Stdio 2010.
I uploaded my website to my domain under the public folder.
First time I lunched my website for testing (http://wecoders.com/Habib_cuizine/Gallery.aspx)
I would revive (Server Error in '/' Application.)
Runtime Error Description: 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.
Details: To enable the details of this
specific error message to be viewable
on remote machines, please create a
tag within a
"web.config" configuration file
located in the root directory of the
current web application. This
tag should then have
its "mode" attribute set to "Off".
<!-- Web.Config Configuration File -->
>
> <configuration>
> <system.web>
> <customErrors mode="Off"/>
> </system.web> </configuration>
Notes: The current error page you are
seeing can be replaced by a custom
error page by modifying the
"defaultRedirect" attribute of the
application's
configuration tag to point to a custom
error page URL.
> <!-- Web.Config Configuration File -->
>
> <configuration>
> <system.web>
> <customErrors mode="RemoteOnly"
> defaultRedirect="mycustompage.htm"/>
> </system.web> </configuration>
To fix this error I added to the webConfig file inside tag:
> <customErrors mode="Off"/>
After that when I lunch the website I would receive a new error as listed bellow:
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: 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.
Source Error:
Line 35: ASP.NET to identify an incoming user.
Line 36: -->
Line 37: <authentication mode="Windows" />
Line 38: <!--
Line 39: The section enables configuration
Source File: \10.0.40.35\wecoders.com\public\habib_cuizine\web.config Line: 37
Please advice how to fix this error and how configure my website which developed using Visual Stdio 2010 to be published in the internet.
Regards,
The key information in this error is this line:
This error can be caused by a virtual
directory not being configured as an
application in IIS.
In IIS, you can have several applications, but they must be configured as an application. Generally, when you create a web project it maps directly to an IIS application.
Check with your hosting service on how to create an IIS application for your web app.
Edit - added
If this is on your server, you can set this up yourself following the instructions in #Frazell Thomas's answer. He beat me to finding that link. To save yourself some reading, you should be able to focus in on the Creating Virtual Directories and Local Web Sites section.
right-click virtual directory (e.g. MyVirtualDirectory)
click convert to application.
Have you configured the virtual directory as an ASP.NET application for the right framework version?
See IIS Setup
Look at these two excerpts:
I uploaded my website to my domain under the public folder.
and
This error can be caused by a virtual directory not being configured as an application in IIS.
It's pretty clear to me that you did exactly what you said you did, and no more, i.e. you transfered the files to the web server, but nothing else. You need to configure that public folder as a virtual directory in IIS as the error is telling you, or it's just not going to work.
Looks like you have <authentication mode="Windows" /> in your web.config file but your hosting provider won't let you use that. Just remove that line.
I got the same problem and my solution was to remove webconfig file from the directory.. then it works..
http://www.velocityreviews.com/forums/t123353-configuration-error.html
If you want to use inetpub/wwwroot/aspnet as your application, remove this
line :
Line 26:
and any other lines which define MachineToApplication beyond application
level
If you want to use d:\inetpub\wwwroot\aspnet\begin\chapter02\ as your
application,
create an IIS Application which points to
d:\inetpub\wwwroot\aspnet\begin\chapter02\
maybe you can refer link above.
For my application, my web.config store in d:\inetpub\wwwroot\aspnet\begin\chapter02\
and when i move the web.config to d:\inetpub\wwwroot\aspnet and the problem is solve.
Please check also does your application have two web.config file.
Looks like this is a very generic message from iis.
in my case we enabled integrated security on web config but forgot to change IIS app pool identity.
Things to check -
go to event viewer on your server and check exact message.
-make sure your app pool and web config using same security(E.g Windows,integrated)
Note: this may not help every time but this might be one of the reason for above error message.
I have the same issue, my application was running on amazon vps, lately i found that bin folder had multiple copies of dll's ...
After removing those copies of dlls like entityframework(copy1).dll, errors were gone....
May be some one will get help...cheers
Removing the web.config-file from the IIS Directory Folder solves the problem.
Try removing the contents of the <compilers> tag in the web.config file. Depending on who you're hosting with, some don't allow the compiler in production.
Your application is trying to compile when it is called and their servers won't allow it.
This wont necessarily fix the problem...but it will tell you what the real problem is. Its currently trying to use a custom error page that doesn't exist.
If you add this line to Web.config (under system.web tag) it should give you the real error.
<system.web>
<!-- added line -->
<customErrors mode="Off"/>
<!-- added line -->
</system.web>
If your project is linq with Sql Database.
Then Simply Check your System Services and Start sql Server Agent Service.
Now your problem is solved.
Just check connectivity between SQL And your App (if you used SQL)

Error while deploying

I am getting the following error while deploying the web application
Server Error in '/FormRelease' Application.
--------------------------------------------------------------------------------
Runtime Error
Description: 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.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
Please help me !
To avoid seeing useless error messages like the one you posted, I use an errorlog database table and additional exception handlers. In general, when an exception occurs, I catch the error, write the error to the error log and then just reraise it to let the system handle it further. Then, when I receive an errorpage like this one, I can check the error log for possible exceptions.
In this case, I suspect that it's a configuration error, though. So it's likely that the system did not even manage to get inside your code or possibly the exception handling itself would fail too, simply because it can't connect to the database.
Possible causes: no access rights to the database, missing modules, invalid configuration, not enough access rights, routing errors, application not set in IIS and many, many other possibilities. To solve these errors and to prevent this happening in a production environment, always deploy to a test environment first, so you can check for any errors and other problems.
As Joel Coehoorn commented, adjust web.config first. But additionally, deploy the web application to a local, clean test environment first! Then you can more easily check any problems without disturbing the production environment. (Use a virtual machine if you can't afford a second test system.)

How to resolve "Server Error in '/' Application" error?

I am trying to deploy an asp.net application in our server while I am receiving the following error.
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: 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.
Source Error:
Line 63: ASP.NET to identify an incoming user.
Line 64: -->
Line 65: <authentication mode="Windows"/>
Line 66: <!--<forms loginUrl="~/SCR.UI/Login1.aspx"/>
Line 67: </authentication>-->
Source File: D:\BarclaysPayamentManagementSystem\scr.ui\web.config Line: 65
What is the reason and how to resolve it?
Please help
You may get this error when trying to browse an ASP.NET application.
The debug information shows that "This error can be caused by a virtual directory not being configured as an application in IIS."
However, this error occurs primarily out of two scenarios.
When you create an new web application using Visual Studio .NET, it automatically creates the virtual directory and configures it as an application. However, if you manually create the virtual directory and it is not configured as an application, then you will not be able to browse the application and may get the above error. The debug information you get as mentioned above, is applicable to this scenario.
To resolve it, right click on the virtual directory - select properties and then click on
"Create" next to the "Application" Label and the text box. It will automatically create the "application" using the virtual directory's name. Now the application can be accessed.
When you have sub-directories in your application, you can have web.config file for the sub-directory. However, there are certain properties which cannot be set in the web.config of the sub-directory such as authentication, session state (you may see that the error message shows the line number where the authentication or session state is declared in the web.config of the sub-directory). The reason is, these settings cannot be overridden at the sub-directory level unless the sub-directory is also configured as an application (as mentioned in the above point).
Mostly, we have the practice of adding web.config in the sub-directory if we want to protect access to the sub-directory files (say, the directory is admin and we wish to protect the admin pages from unauthorized users).
I had this error when the .NET version was wrong - make sure the site is configured to the one you need.
See aspnet_regiis.exe for details.
I had this error with VS 2015, in my case going to the project properties page, Web tab, and clicking on Create Virtual Directory button in Servers section solved it
It sounds like the admin has locked the "authentication" node of the web.config, which one can do in the global web.config pretty easily. Or, in a nutshell, this is working as designed.
I just had the same issue on visual studio 2012. For a internet application project.
How to resolve “Server Error in '/' Application” error?
Searching for answer I came across this post, but none of these answer help me.
Than I found another post here on stackoverflow that has the answer for resolving this issue.
Specified argument was out of the range of valid values. Parameter name: site
When you create an new web application using visual studio.net, it automatically creates the virtual directory and configures it as an application. However, if you manually create the virtual directory and it is not configured as an application, then you will not be able to browse the application and may get the above error.
I also got this error when I moved an entity framework edmx file into a "Models" sub-folder. This automatically changed the metadata in my connection string setting in my app.config.
So before the connection string changed... it looked something like this:
<connectionStrings>
<add name="MyDbEntities" connectionString="metadata=res://*/MyDb.csdl|res://*/MyDb.ssdl|res://*/MyDb.msl; ...
</connectionStrings>
And after... it added the "Models" subfolder name (btw... it also added "Models" to the namespace for the EF classes generated) and the connection string now looks something like this:
<connectionStrings>
<add name="MyDbEntities" connectionString="metadata=res://*/Models.MyDb.csdl|res://*/Models.MyDb.ssdl|res://*/Models.MyDb.msl; ...
</connectionStrings>
I have a website project that references this Entity Framework DB project. But its web.config did not have the updates to the connection string... and that's when I started getting the compilation error being discussed here.
To fix this error, I updated the connection string in the web.config in the website project to match the app.config in my EntityFramework project.
vs2017 just added in these lines to csproj.user file
<IISExpressAnonymousAuthentication>enabled</IISExpressAnonymousAuthentication>
<IISExpressWindowsAuthentication>enabled</IISExpressWindowsAuthentication>
<IISExpressUseClassicPipelineMode>false</IISExpressUseClassicPipelineMode>
with these lines in Web.config
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxRequestLength="1048576" />
<identity impersonate="false" />
<authentication mode="Windows" />
<authorization>
<allow users="yourNTusername" />
<deny users="?" />
</authorization>
And it worked
I opened the Properties window for the website project in question and changed Windows Authentication to "Enabled" and that resolved my issue in VS 2019.
The error message is quite clear: you have a configuration element in a web.config file in a subfolder of your web app that is not allowed at that level - OR you forgot to configure your web application as IIS application.
Example: you try to override application level settings like forms authentication parameters in a web.config in a subfolder of your application

Resources