ASP.NET MVC Issues - Namespace not found - asp.net-mvc

Basically any place that a MVC resource is needed in my application, it is being listed in the error list (234 errors, almost every single one is the exact same error).
I am able to get intellisense when I type System.Web.Mvc., and add a Controller, but after building, the line which the Controller was added to shows in blue font, but it is underlined.
I have literally tried so many solutions from Stack, most often discussed is:
Remove reference to System.Web.Mvc and re-add. Set copy local to true.
Screenshot of subset of errors below.
I am surprised that it is being flagged here, when it is recognizing Controller in the inheritance.
Here too

This is never the nice answer... I recreated the solution, and very carefully chose all of my options when configuring. I built to the browser after all changes, and so far everything is working out.

Related

Umbraco 6 - Published page throws 404 in specific scenarios

I am running an instance of Umbraco 6.1.x and it has started throwing 404 on published pages.
My page structure is as follows,
Content
Home
About
Course
...
Component
Home
About
Course
Where component holds all resources and modules (HTML sections and stuff) for a page and using a partial view macro I dynamically load all components at runtime for a specific page.
We are facing an issue where we get 404 on every page after a full republish once we hit the HomePage. Before hitting home page they are all fine, but the moment we hit the homepage they are all throwing 404. By overriding the handlers I found out that they are hitting ~/umbraco/RenderMvc!
Any idea what can cause this?
Thanks in advance.
EDIT:
It is actually throwing:
No template exists to render the document at url '/'
considering the aforementioned scenario.
I have proper allowed template setup and property on nodes are showing the correct template associated with the respective items. Not sure why it's losing template info. I can force it to load under correct template using ?altTemplate=templateName.
Some pointers, we have a view in Views/Shared folder (apart from macro partials) tied to a surface controller.
One thing I would like to say is, we are using nested (library.RenderMacroContent with Umbraco markup) in our partial views and I have realized that the whole page throws 404 if there's a page with a link to the broken page which is broken (i.e. page got re-created and on t==e of the components is holding a link to the page with previous id). Suggestions?
did you get to the bottom of this? We're having exactly the same problem at the moment, on the same version of Umbraco.
I've noticed that when it happens, the umbraco.config becomes either corrupt or rolls back to a much, much earlier version, with all sorts of attributes missing. This lead us to believe it was a sync issue between the DB and umbraco.config.
We initially thought we had solved it by deleting App_Data > TEMP > ExamineIndex and recycling the app pool etc. Maybe give this ago, as it fixed it for a while for us, but alas, the demon has reared its ugly head once more. We are still in a full on dev stage though, so the constant changing may be complicating it further for us - perhaps it will be a fix for you.
If you have any more info, or even a fix, it would be greatly appreciated.
Cheers
EDIT:
Ok, I think I've solved this now, but only time will tell. Try emptying your recycle bin & then republish entire site.
I managed to consistently recreate the bug using IIS SEO site analysis. Each time I did this, the log threw up an error 'cannot find node id xyz', turns out that (and other) nodes were in the recycle bin. Upon emptying it the errors stopped. Good luck!

ASP.NET MVC 3 RC and custom ViewEngine to allow for externally loaded Views

I'm playing around a little with dividing up a MVC-site into several assemblies (ran into some issues earlier).
Now I have almost everything working, got the main MVC project that loads in any external assemblies it can find. The external assemblies are basically external areas. When I had it copy the Views and web.config to the main-sites Areas-folder everything worked just fine. Now, that folder will most likely start to get a little bloated after a while, so I thought I'd try to add in the Views as resources in the area-assembly instead, see how that worked.
Created my own VirtualPathProvider and my own VirtualFile, registered them with the HostingEnvironment thinking all was well. Turns out it only uses the VirtualPathProvider added to the HostingEnvironment at the first load, not by the following View-loads by the ViewEngine.. Ok fine, found a few examples of how you could get around this by implementing your own ViewEngine to use your own VPP. But yeah, this doesn't seem to be a workable solution for MVC 3..
As it turns out, neither RazorViewEngine nor WebFormViewEngine implement two of the "key-functions" it seems, FileExists and IsValidPath. These are inherited from BuildManagerViewEngine, and you know what? These methods are marked as sealed..
Anyone who has tried this with MVC 3 and perhaps could nudge me in the right direction? I've been staring at the MVC 3 source now for quite a while but I just can't see any way of doing this..
Now I feel a little stupid, it seems I loaded the VPP too late.. Had it in Application_Start, but when I moved it to my PreApplicationStartMethod instead, it was used by the ViewEngine. (So no implementation of ViewEngine seems to be needed, wey!)
Problem now is that when I try to get to a View that's stored as a resource, I get to download it instead of having it rendered.. But that's something different from this so!

After updating to MVC3 RC, why don't my View Data classes show up in the Add View dialog

Background:
I just updated to the RC of MVC3, and when I went to add a Stongly-Typed View, the list of classes didn't contain the class I wanted, which has been built in my project.
Now, I did compile my project, and already have several views that work correct, but their model also doesn't show up in this list.
Since the change to this dialog in RC, what is the new criteria that makes a class show up, considering none of them in my project showed up.
They altered the way that they're displayed in MVC 3 RC. For example previously you would just scroll to:
Project.Data.Models.User
Now it's organized in reverse
User (Project.Data.Models)
This is most likely your problem. What would be nice is if they had a filter to show only local objects rather than all referenced assemblies
Had the same problem. Clean solution and build and my view models started showing up...

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

Changing ASP.NET MVC default folder structure

Is it possible to change around the folder organization to the following and still have MVC work.
P1
Controllers
Models
Views
P2
Controllers
Models
Views
etc..
This looks a lot like the new feature area's which is available in MVC 2 though it is currently in preview and will be release with VS 2010.
If you want to do it yourself without using areas then check out this article on view engines
as said before, the Areas feature is what you are looking for.
If you are using vs2010, then although you have MVC2, you don't have the tools for creating the areas - these are only available on vs 2008, when you install the MVC2 rc
to make it happen follow the instructions at the following link: http://msdn.microsoft.com/en-us/library/ee671793%28VS.100%29.aspx
as you can see the menu options are missing so:
download the example project from there.
build the directory structure at your solution according to the example
change the AreaRegistration.cs to match your area name
add AreaRegistration.RegisterAllAreas(); at the RegisterRoutes function at the global.asax, right after the IgnoreRoute
NOTE: the namespaces shuold contain .Areas.
for More explanations search at stackoverflow for asp-net-mvc-2-beta-single-project-area-registration-getting-http-404 (since this is the first time i post an answer - SO doesn't let me append more then 1 link, go fugure..)
Hope this helps
Should be doable, I think the default folder structure is just a suggestion. I've seen before in some documentation that larger projects would likely be split up differently, possibly even among multiple assemblies.
The only thing I would think would cause some trouble would be the views. Since controller actions are mapped to them only by file name. I know there's some way to change them, but I have not had to do so yet.
You can create your own viewengine to solve the paths. That sounds like a very strange idea, but the ViewEngine class is actually responsible for 2 things: locating a view and rendering a view to the httpresponse. The thing you have to change is the locating part, you can just inherit the default aspxviewengine and change the view locating part.

Resources