Error.aspx - how to turn off? - asp.net-mvc

I have my Error.aspx being loaded upon a server error but the problem is it has no information on it and I can't track down how or why it is being loaded. I searched my project for "Error.aspx" and nothing is coming up. How do you get a stack trace or something that is half way useful?
Thanks

Are you using a HandleError attribute on any of your controllers? If this attribute is present, when an unhandled exception occurs ASP.NET MVC will look for a view named Error.aspx in the controller's view folder. If it doesn't find one it then looks in the shared view folders. If you have default controllers in your project (ie. HomeController, AccountController) then you'll notice that they have the attribute.

Look in your web.config file for the <customErrors> element.
It probably specifies defaultRedirect="Error.aspx" and mode="On". Set mode="Off" or create an error page.
Read the MSDN docs: customErrors Element (ASP.NET Settings Schema)
Note: It is also possible that the <customErrors> element is being inherited from a .config file higher up at global server level (one of the root web.config files or machine.config). Check these if you cannot find <customErrors> in your application web.config file.

Related

Why is Glimpse still running?

I made glimpse defaultRuntimePolicy Off but it still shows an error like this
Unable to define EFProfiledDbProviderServices class of type 'GlimpseDbProviderServices'. Please check that your web.config defines a <DbProviderFactories> section underneath <system.data>
shouldn't glimpse be out of asp.net mvc pipeline after making it off?
Update :
I also commented all the glimpse related part in web.config but I still get the same above error
The reason is that even when you disable Glimpse completely through the web.config, which makes sure Glimpse is not collecting any information during request processing, that there are still assemblies, like Glimpse.Ado and Glimpse.EF*, that have a PreApplicationStartMethod attribute defined, which means that some hooks are being put in place, even though they are not going to do anything when requests are being processed.
The solution is to remove the Glimpse.EF* assembly, and maybe the Glimpse.Ado assembly as well, from you bin directory.

.NET MVC - accessing .xhtml file

I have created an Area for XForms and when I try to return view("index.xhtml") the framework resolves the view as index.xhtml.aspx or index.xhtml.cshtml.
I tried routes.IgnoreRoute("{resource}.*xhtml/{*pathinfo}"); in global.asax.
Either I am not sure what URL to use (am I still hitting the controller or going straight at the .xhtml file in the views folder?) OR I made a mistake in my ignoreroute.
Any help appreciated.
If you are trying to have the action just write the content of index.xhtml, you'll need to do return File("index.html", "application/xhtml+xml"). View/PartialView assume you want the specified view file parsed and executed using the currently configured view engine.
You can't/shouldn't put static files you want remote users to be able to hit directly in your ~/Views folder. MVC places a web.config file in this folder that prevents files in this location from being served.
So, either have your controller action return the file as I mentioned above, or move the xhtml files into some other folder in your application that is not restricted. Then your route should work and your files should be served statically.

Load Web.Config as embedded resource inside a DLL in ASP.NET MVC

Following on from my earlier question around loading views from DLLs under ASP.NET MVC, I've come across the issue of having Views and Controls be strongly typed. An exception is thrown indicating that the type cannot be resolved.
I found this article which describes implementing a web.config section which allows that strongly typed view declaration to be parsed correctly.
How can I parse a web.config that is embedded in a class library as a resource? Would this require a custom build provider?
I think your confused?
All you have to do is create a web.config file and put the code in the article you found in the folder where you are storing your views. Thats it.

Why isn't MVC using Error.aspx?

I'm trying to add some security to my ASP.NET 1.0 MVC app (VB), but I can't get it to work. At the top of my controller, I've got:
<HandleError()> _
Public Class HomeController
I'm overriding OnActionExecuting and throwing a SecurityException if the user is not in the proper role.
Everything I've read states that this should by default look for Error.aspx first in the current folder (Home) then in the Shared folder. I've got Error.aspx in both folders, and all I'm getting is a "Security Exception" yellow screen of death.
What am I missing?
do you have customErrors=On in your web.config
here
Do you have in your web.config? If mode="Off" or if you're accessing the site from the same box and mode="RemoteOnly", the debug page is shown instead of the error.aspx view.
If this is not the case, try creating an action on a controller that returns View("Error") and see what happens. I just had this problem recently and it was due to an error in the Error.aspx view itself. Rather than tell you there's a problem with the error view, the framework just goes ahead and displays the YSOD with the original error information.

ASP.NET MVC and two Web.config files

Where is the Web.config supposed to go in an ASP.NET MVC project?
I just ran into an error trying to do this:
_cnstr = System.Configuration.ConfigurationManager.
ConnectionStrings["production"].ConnectionString;
The default MVC template puts the Web.config at the root of the project.
If you go into the properties of a project (the screen with the vertical tabs). Go to settings and try to create an application setting, it will prompt you that you don't have a config file. When it creates the file it does it at the base of the Views folder. So now I have two Web.config files. Is this how it supposed to be?
And I guess I should put my connection string in the "views" web.config to avoid the error.
Thoughts? Is this a bug in the last release of the ASP.NET MVC bits?
UPDATE:
See David's answer
The settings should go into the web.config at the application root. The web.config in the views folder is there to block direct access to the view aspx pages which should only get served through controllers.
(And: I tried creating application settings on my machine, with ASP.NET MVC RC 1 installed, using a newly created mvc web application. They get added to the web.config at the application root.)

Resources