Has anyone seen an ASP.NET MVC 4 partial view render like this before?
Of three development workstations, two display the it correctly, and one does this. Obviously, it is something with the configuration of the third machine, but I cannot seem to figure out what.
Are you using VS2013 Preview? If so, there was a bug with ASP.NET partial render, try getting a newer version.
Show your code.
Keep in mind that partial view code has changed from MVC3 to MVC4.
An example would given in your compiler.
Or look here: http://www.asp.net/mvc
Related
I am working on an existing Asp.net MVC 4 project and I want to know if there is any way to check in solution explorer that if view is partial or not. Please suggest.
Partials often have an underscore prefix in their name. Other than that, nothing really separates them from other views.
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.
Can I upgrade my MVC2 project to MVC3 and continue to use my ASPX views, AND at the same time start writing some new views in Razor?
More specifically, Can I take an ASPX view page, and a Razor control in it? Would such a thing be possible?
Any other things one should look out for?
You can definitely mix view engines across totally separate views. As for putting Razor "controls" in an ASPX page, if you use RenderPartial, it should work.
One thing I would watch out for is that if you use Master Pages then you may end up duplicating them for both view engines. I had a good ol' WebForms Master Page, used by all my regular .aspx content files, but creating a new view using Razor means I have to use a duplicate Razor layout page alongside that old Master Page.
I haven't looked into it too much, but at first try I get 'The file "~/Views/Shared/Site.Master" could not be rendered, because it does not exist or is not a valid page.' and certainly there's nothing in Scott Gu's blog entry introducing Razor to suggest you can combine them, but I could be all wrong here.
http://www.hanselman.com/blog/MixingRazorViewsAndWebFormsMasterPagesWithASPNETMVC3.aspx
For how to mix view engine master pages...
In my MVC 2 (RC) I do not see the Codebehind files, Have they been deliberately remvoed ?
If you had a proper install of MVC 1, the codebehind files would already be gone. They are sometimes considered harmfull as they are likely to violate the MVC pattern.
Codebehind is still possible though, yet you'll need to add them by hand. See f.e. how to add a code-behind page to a view or partial view.
The closest thing to codebehind in MVC would be the controller, although it's not really comparable since the controller have no clue of whats going on in the view.
I was using MVC 1.0 RTM, and the Haack solution for Areas
I just recently moved to MVC2 RC and I'm using single project areas with my controllers in separate assemblies. My problem is that in the MVC 1 solution I ALWAYS had "area" in my RouteData.Values collection, in MVC2 RC it doesn't exist. Do you know how to get this in MVC2 RC?
Thanks in advance!
This is kept in a DataToken for the route. Namely, route.DataTokens["area"]. Look at AreaHelpers.cs in the MVC source for details.
By the way, when you ask a question like this, you should show the code you're using which is not working. It makes it much easier to supply an answer. Right now, I don't know if you've already tried the method above, but are making an error with it, or if you haven't discovered this yet.