elmah is emailing me exceptions for missing controllers like so:
System.Web.HttpException: The controller for path
'/Scripts/modernizr-2.0.6-development-only.js' was not found or does
not implement IController.
I added some ignore routes to try and let the app know that scripts isn't a controller and to ignore all .js and .css files like so:
routes.IgnoreRoute("scripts/*");
routes.IgnoreRoute("*.js|css");
It's still emailing me the exception. at this point I want to just suppress the error because every single time I hit a page on the app, it triggers this email.
any suggestions to cure this?
Check that the script it is looking for actually exists in the site. I have had problems like this reported in Elmah, and as I remember, it was after a js library had been updated by NuGet, but the references in the views had not.
Hope that helps.
Related
I'm trying to run my ASP.NET MVC 5.2.3.0 application as nested application so that I can access it as a subfolder, like http://example.com/my-application.
I've added it to an existing application by choosing Add Application a chosen separate application pool.
When I run my-application on its own URL it works fine however when I try to run it as http://example.com/my-application it refuses to render bundles, neither style nor js.
What I have tried so far:
I have tried to enable and disable bundling and minification. When it's disabled Styles.Render adds nothing to markup. When it's enabled invalid link to bundle is added to markup, for example <link href="/calc/bundles/styles/mainlayout?v=" rel="stylesheet"/> and the link returns empty document.
I have tried to put my-application to empty website to ensure no side effects inherited. No difference here.
I have tried to put brand new application side by side with my-application and bundling worked fine there so it must be something wrong with my application and I can not find what exactly.
I have tried to ILSpy System.Web.Optimization code but couldn't find any help there.
I have failed to debug System.Web.Optimization as my VS just hung.
I didn't find any conflicting routes with my-application address.
If anyone faced the same issue then any advice appreciated.
Thanks.
UPDATE: I found what causes the issue. We intensively use T4MVC and we use it for bundles configuration as well. So our bundle declaration looks something like:
bundles.Add(new ScriptBundle("~/bundles/scripts")
.Include("~" + Links.Scripts.Script1_js, "~" + Links.Scripts.Script2_js));
And "~" + Links.Scripts.Script1_js for nested application gives me ~/my-application/scripts/script1.js while VirtualPathProvider from inside Include method expects it to be ~/scripts/script1.js.
So the question transforms into: does anyone know how to prevent T4MVC from adding nested application path onto static files links so that application isn't aware of being nested? I bet #David Ebbo knows how to achieve this :)
I've got an ASP.NET MVC app where the Application_Start event appears to not be firing. The symptoms are that an NLog log statement in that handler does not generate a log entry, and none of my routes get populated (so all my requests for controller actions return a 404).
Static files on the server (eg, favicon.ico) are served correctly.
I have log statements in Application_BeginRequest and Application_EndRequest. Those do generate log entries, both for the controller methods and the static files, so I feel pretty confident the app pool is configured correctly.
The problem shows up on our staging server, but not my local machine or our dev server.
Any idea what would cause this?
It ended up being a combination of things. The root cause was inconsistent versions of DLL's, and I solved that by configuring the project to copy the problem assemblies to my bin folder. On top of that, there was some code in Application_Error that was preventing the actual exception from being shown.
Ok, this one is killing me. It makes no sense at all... I've setup a simple MVC.Net project. Everything appears to work fine. I get the typical 404 errors, and wanted to change that so I started looking into that... That got me poking around in the Application_Error method in the global.asax. It all appears to work as I would expect.
Here's the problem. I put the following line of code (just this line) in the Application_Error method and made a breakpoint to see what the error traffic was like so I could test things, etc.
Exception ex = Server.GetLastError();
I'm running the project in debug, and it comes back with an HttpException with an error code 404
The controller for path
'/Content/jquery-ui-1.8.7.custom.min.js'
was not found or does not implement
IController.
So far nothing too strange, right? So, I did a search for this offending call. I used the Visual Studio Find function and searched Entire Solution for /Content/jquery-ui-1.8.7.custom.min.js. There were no calls to this file. I searched for jquery-ui-1.8.7.custom.min.js and found all the expected calls to that file which look for it in the /Scripts/ directory.
In the /Content/ directory I have my .css files, and some images in the Images subdirectory...
I'm hoping there is just something strange that I don't know about with MVC.Net that you guys have already figured out that causes this quirkiness. It just makes no sense... I could see getting the 404 if there was a call to that file, but there isn't...
Any guidance on even some troubleshooting ideas would be helpful at this point. I'm stumped...
Thanks guys!
Just a suggestion to help you debug: Download Fiddler and check the actually HTTP requests being made. Note: When debugging using localhost, make a new hosts entry and point 127.0.0.1 to some other name, otherwise Fiddler won't track the requests.
We recently upgraded a project to MVC 2 and we'd like to use Areas but there is an issue.
We have created a new area, setup a controller, configured a route, and created a view in the correct location. When we run the code it successfully finds the route and hits the controller but when it goes to render the view there is an exception.
The web forms view engine doesn't seem to be looking in the Areas section for views. The error we're seeing is:
~/Views/<ControllerName>/<ViewName>.aspx
~/Views/<ControllerName>/<ViewName>.ascx
~/Views/Shared/<ViewName>.aspx
~/Views/Shared/<ViewName>.ascx
When it should be:
~/<AreaName>/Views/<ControllerName>/<ViewName>.aspx
~/<AreaName>/Views/<ControllerName>/<ViewName>.ascx
~/<AreaName>/Views/Shared/<ViewName>.aspx
~/<AreaName>/Views/Shared/<ViewName>.ascx
~/Views/<ControllerName>/<ViewName>.aspx
~/Views/<ControllerName>/<ViewName>.ascx
~/Views/Shared/<ViewName>.aspx
~/Views/Shared/<ViewName>.ascx
This would indicate that it's still somehow using the MVC 1 dll but we've looked carefully and can find only references to the V2 of MVC (there was a V1 reference in xVal, a third party DLL, but fixing that didn't make a difference).
I can only imagine that we missed something when we did the upgrade or that we've got some unusual edge case because there doesn't seem to be anything on the web that matches the problem we're experiencing.
What things could we look at that might help us resolve this issue?
Thanks in advance for any help provided.
Cheers,
Zac
What things could we look at that might help us resolve this issue?
Make sure Area Routes are Registered AreaRegistration.RegisterAllAreas(); are registered first. Area routes need to be registered as well.
Make sure generated URL links have the area name included as one of the arguments when using ActionLink and other related URL helpers
Sometimes just delete and re-add the Area from scratch. Sounds silly, but it works.
The related SO question on the left hand side of this page may help. I have linked one I think may be of value
I have a project that compiles and runs fine on my development machine but when I run it on the web server I get the following error.
Parser Error Message: The file '/Views/Shared/Main.master.cs' does not exist.
The file mentioned does not exist on the server but the file '/Views/Shared/Main.master' does.
I use the 'Publish' command to upload the project. Is it missing the cs files?
Is there some setting where it does just in-time compiling that need to turn off?
I stumbled upon this solution.
The master page has the following attribute CodeFile="Main.master.cs". When I replaced this with CodeBehind="Main.master.cs" it works as expected.
The file originally came from an older web application but I don't know what the difference means. If someone else can come up with a better explanation I will accept their answer instead of this one.
Glad you got it figured out. It may come from an issue when converting from "Web Site" to "Web Application" project type.
http://aspadvice.com/blogs/ssmith/archive/2007/01/24/CodeFile-or-CodeBehind.aspx
Usually the files are marked with a reference to a dll that exists in the bin, e.g. App_Web_nnnnn in the inherits declaration of Main.master. Is that the case for that file on the web server and does the referenced dll exist in the bin? If not then it may not be pre-compiling as it should.
As far as I have seen with MVC, I don't think you even need the code-behind pages, do you?
I have removed the references from any pages in my app that were there for any reason.
Also, when you create a new View, I don't think it even creates the code-behind page in MVC, does it? (Really threw me to start with!!)