MVC searching for view in wrong location - asp.net-mvc

Base URL to run the my MVC app is:
http://localhost/RealSuiteApps/RealHelp/-1/Inbox/
And... I get this exception:
I know what it means :) But I dont understand why I get it, I have everything in place and the exact same code was working perfectly yesterday. What could go wrong?
Here is the code, you see I have InboxController, Index action in it, and of course the view under Views/Inbox/Index view

Most likely, this is a routing issue. Based on the error message, the Index action that's being loaded is actually in HomeController. MVC is searching /Views/Home/ for the view, so that means the controller is HomeController. You should probably post your RouteConfig.cs file for a more thorough answer, but generally, I can tell you that you need to look at your routes and figure out why the URL is not going where it should.

Related

Asp.NET MVC 5 Trace

I am having some issue on MVC 5, when I am in any controller action the flow redirect to LogOff action method on Account controller.
I didn't find why that is happening so I want to know if there is any Trace or Debug, or Log, or whatever that I should look at to see why this is happening.
Any Idea?
I think you have mentioned this route logic somewhere thats why it is redirecting to logoff action method. Please check routeconfig, web.config and layout, where i think you will find something regarding this by which you can resolve this issue.

MVC4 Portable Areas?

Does MVC4 remove the MVCContrib requirement to achieve portable areas? Or is that still required?
I gave it a shot w/o MVCContrib and unfortunately I'm stuck with a typical "The view 'Index' or its master was not found or no view engine supports the searched locations." exception.
The list of searched locations includes "~/Areas/Inbox/Views/Default/Index.cshtml" which is technically correct, but it's just not finding the view.
Some explanation:
I have a main MVC4 application and a "plugin" (if you will) MVC4 app that contains an area called Inbox with a controller and view named Default. I reference this plugin app in the main app and I can hit a breakpoint in DefaultController's Index method where the View is returned - so I know the main app is engaging the plugin app and routing the requests to the proper controller and all that. When not running, if I cursor over the return View() statement in DefaultController the balloon shows the desired view, it's just not found at runtime.
Has anyone encountered this? I'm sure it's something really simple and a stupid oversight on my part, but after hours of trying, I can't find a solution. Thanks in advance!
MvcContrib is not a part of MVC, so no. MVC4 does not include Portable Areas. MvcContrib is not like MvcFutures where it's likely that at some point the code will be rolled into the main project. This is code that is contributed by third parties.
For each view, edit the Properties and set the Build Action to Embedded Resource.

Error occur while adding controller

I am developing MVC 3 application and using razor syntax.(EF 4.0)
I am trying to add controller to my App. but whenever I try to add the controller I get the following error.
I am trying to add controller in test copy as well sourcesafe copy...
And the error is....
When I try add the controller in SourceSafe copy of the same application , below error comes...
How to solve it ?
Look into this article, your solution is most likely there.
Edit
Please take a look into this article dealing with specifically "Unsopported context type" during controller scaffolding: Unsupported context type in controller wizard.
Hope you can get ideas and solution from there...
Hope this helps

MVC.Net site is throwing a 404 error for a resource/page that isn't being called

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.

ASP.Net MVC 2 Areas: The partial view '...' was not found

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

Resources