The attribute 'debug' has been locked in a higher level configuration - asp.net-mvc

Im trying to upload a MVC site to a server but it just seems it wont play ball. Never had such weird errors for uploading a mvc site.
Get this message when I navigate to the web page.
The attribute 'debug' has been locked in a higher level configuration.
What the h... does that mean?
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.
some part of the web.config that I have been messing around with:
<customErrors mode="Off">
</customErrors>
<compilation debug="false" />

It means that the debug attribute has been set at machine level and you are not allowed to change it. This is done in the global IIS configuration file that you won't have access to. In effect, a web.config just inherits from that and all your XML is just overriding or adding to those values.
Now I assume it's been locked to prevent debug="true", this means you can just remove that attribute completely, which means you can remove the entire compilation element.

Related

MVC web.config Error

What is the reason for this error and how to solve.
This configuration section cannot be used at this path. This happens
when the site administrator has locked access to this section using
<location allowOverride="false"> from an inherited configuration file.
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.
There is a hierarchy of config files that sets machine-level and then application-level restrictions over configuration sections.
If in your website you try to override one of the locked down sections up the hierarchy you will get this error.
For more information refer to these docs:
https://learn.microsoft.com/en-us/iis/get-started/planning-your-iis-architecture/the-configuration-system-in-iis-7#hierarchy

Published website, but it now displays an error page instead of homepage

The error states:
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.
Here's the address where you can see the error:
http://connellchamberofcommerce.com/
I have a feeling there's something in the web.config I'm supposed to change now that the website is online instead of my local machine, but this is my first ASP.Net website and I don't know what it is.
Is there something simple I'm missing that you're supposed to do when publishing an ASP.Net website?
In order to diagnose errors for your initial deployment, you can make the following change to your web.config.
<configuration>
...
<system.web>
...
<customErrors mode="Off" />
...
</system.web>
...
</configuration>
You should change this back to RemoteOnly when you have resolved all your deployment exceptions to prevent unsavory folks from learning too much about your architecture.

How to Show Complex Error Page on Server

I have written an ASP.NET MVC App that is running on a Google Compute Engine. The app is getting a 500 Error on the main Index page that does not occur when running on my local machine.
I am trying to get the complex error page to show from the server, as it is much easier to view them on the web page for hotfixing issues than to delve into the Google Cloud Console to retrieve them. I do not want custom errors, just the same amount of depth that gets shown when running on my local machine.
I have tried:
Removing the existing HTTP Global Filter
Adding <customErrors
mode="Off"/><compilation debug="true"/> to my System.Web in
Web.config
Adding <httpErrors errorMode="Detailed" /><asp
scriptErrorSentToBrowser="true"/> to my System.WebServer in
Web.config
Publishing as debug
Ideas? I'm sure theres a publish setting I'm missing somewhere.
Adding a constructor to the page controller finally provided the detailed error log. If you have taken all of the steps above to get the log, and it still has yet to show, ensure there are constructors for all view controllers involved. Even if the constructor is blank.
I still need to delve into my particular crash issue, but at least I can get an idea where to start.

IIS 8.5 - Application initialization not working

I have installed Application Initialization, set the website's application pool Start Mode to "Always Running", and set Preload Enabled = "True" in the advanced settings of the website.
However, if I recycle the application pool manually and wait 10 seconds, when I then reload the website, I still have to wait another 10 seconds for the website to warm up. This indicates that the website is not starting.
Looking at task manager, I can see that the application pool is running the whole time - even after a recycle. However, the memory usage is very low until I make my own request to the website.
One thing I have noticed is that I do not have a "Start Automatically" setting in the advanced settings of my website as per this link:
https://blogs.msdn.microsoft.com/vijaysk/2012/10/11/iis-8-whats-new-website-settings/
How can I get my application to auto-start?
It turned out to be a whole load of settings which all had to be correct. You go through all of the steps to install the relevant components and make the various config changes as per this link: http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-application-initialization
The key part which was missing for me was an instruction in the Web.config as below. I had it going to just "/Login" which is a valid route, but as soon as I switched it to "/[Controller]/[Action]" it worked.
The advantage of this route is that you can create a custom action which will also hit the database (initialising Entity Framework), and perform any other slow initialisation you wish. For me, I just read a record out of a DB table, so I get ASP.NET auto-starting, and also save the few seconds it takes to warm up EF too :)
<system.webServer>
<applicationInitialization doAppInitAfterRestart="true" skipManagedModules="false">
<add initializationPage="/Login/WarmUp" />
</applicationInitialization>
</system.webServer>
Try Application Initialization setup:
I had similar issues and tried very hard with IIS 8.5 Windows Server 2012 R2. Everything in the IIS was set correctly after referring to so many sites however had missed the Application Initialization setup. Refer to the below link, Setup section.
https://www.iis.net/configreference/system.webserver/applicationinitialization
There are multiple .config locations where these settings can be set.
Machine applicationHost.config (c:\windows\system32\inetsrv\Config)
Website web.config (c:\inetpub\wwwroot for Default Web Site)
Application web.config
I tried all but was only successful in configuring 3, the application web.config.
My specific use case was calling a GET method on a WCF service.
The steps for application initialization are found in the other answers too. Here is one that was most helpful. IIS 8.0 Application Initialization
Install the Windows feature Application Initialization (Web-AppInit)
Set the IIS app pool Start mode = AlwaysRunning
Set the IIS application Preload Enabled = true
Add to the application web.config
<system.webServer>
<applicationInitialization doAppInitAfterRestart="true" skipManagedModules="true">
<add initializationPage="/Service.svc/Method/Parameter" />
</applicationInitialization>
</system.webServer>
Recycle app pool
Check that the app initialized.
The thing I would like to point out is that the initialization page is relative to the application NOT to the root of the website/domain so if my absolute path is
domain.com/path1/path2/Service.svc
I would not include /path1/path2 in the initializationPage parameter.
These articles are very good:
Use IIS Application Initialization for keeping ASP.NET Apps alive
IIS 8.0 Application Initialization
However in my case there was a problem with installing the Application Initialization Role.
Check your IIS App's Modules listing. Ensure ApplicationInitializationModule is present.
I needed to uninstall/re-install this module.
I have no idea what happened as this appeared to work at first, then weeks later during development it stopped. No amount of tinkering/rework fixed it and I started to suspect I never actually saw this working.
Issue resolved upon uninstall/re-install Applicaion Initialization Module role.
If anyone's wondering what to do in MVC when you have multiple areas to initialise, you need to put the area at the start, all within the root web.config file. I was stuck for a while trying to put it in the area's web.config. Also it's perfectly compatible with hybrid applications.
<add initializationPage="/NotMVC.aspx" />
<add initializationPage="/Area1/Controller/Action" />
<add initializationPage="/Area2/Controller/Action" />

Deploying ASP MVC 5 App with IIS 7.5

I try to deploy ASP MVC 5 app in virtual directory (without creating new iis application)
I use IIS 7.5
I already put
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true" />
in web.config file.
But when i go to app url with IE browser it shows me just directory listing like in screenshot below
Is there a way to deploy MVC 5 in virtual directory and make it work like usual MVC application?
You need to convert the virtual directory to application. Right click on it in the IIS management console and choose Convert To Application.... Also make sure that the associated application is configured to use Integrated Pipeline Mode.
I solved this problem earlier in my production environment by checking the directory pointer in IIS. Apparently when I unzipped the deployed site from one server to the next, the zip utility made an extra level, so IIS was pointing to /MyProject when the files were in /MyProject/MyProject. I had a little better clue though, you have Document Browsing enabled based on that screen shot, make sure not to do that in production. I set the site to log custom errors and got a 403.14 response, from there found a blog on my mistake. You need to setup the environment to find the specific module that's failing, I think something to do with trace routes, idk. I'm a software developer that always gets forced into doing devOps; was googling my own problem and thought I'd throw you a line. Without a specific error message, all I can tell you is IIS is not connecting to .NET; something is not configured correctly. Turn off directory browsing, google how to get good error logs back, and let us know the status code so we can help you: 403.14, 401, 500, 404? Also give us the module that's failing. If it's the last one on the handler list, guess what, IIS isn't connecting to the app, which I suspect is your case.

Resources