MVC3 Razor view engine, error when creating a partial view - asp.net-mvc

I'm evaluating MVC 3 and Razor. All was going well until I tried right clicking on Views\Shared and Add..View... I check the 'Create a partial' checkbox, strongly typed view, choose an entity, Razor, Empty... When I press OK, I get a huge error. Template Processing resulted in 1 Errors. The following exception was thrown: System.IO.FileNotFoundException: Could not load file or assembly 'Domain, Version-1.0.0.0... Trying this on a coworkers machine gave me no problems. We have the same version of MVC 3 installed. Any ideas why her's works just fine but I am getting this error? I have tried running as Administrator as well. Still no luck. Oddly if I uncheck strongly typed view, the partial view is created without a problem. Does anyone know how I can remedy this?
Thanks For any tips or help,
~ck in San Diego

I'm new to this and have the same issue. A workaround seems to be to remove the reference, create the partial view and than add the reference again. So it seems to be something inside this reference (corrupt).

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!

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

Upgraded to MVC 3: CS0103: The name 'View' does not exist in the current context

I have just updated to ASP.NET MVC 3 RC2.
The sample app I am working on now produces the following error, whenever a cshtml view is rendered:
CS0103: The name 'View' does not exist in the current context
It fails on the line:
#{
View.Title = "MyView";
}
... and fails anywhere else it encounters View in the code on the Razor file.
I have copied the web.config from a new apps View folder to my sample app, but the problem persists.
A brand new application runs without problems.
I have also rebuilt the solution, run Clean Solution. No joy.
I haven't worked on the sample for a few days. So it might be an issue that has nothing to do with RC2...
It's been renamed 'ViewBag'. You can read more about the changes from RC1 -> RC2 here
I had the same problem, but I just tried to guess what to use now, I ended up using:
#Page.Title = "The title"
and it worked, though I'm not sure what is the "best practice" now
Also, I thought that the ViewBag is what used to be ViewModel, not just View
I'm adding this in case anyone else comes across it. Another possible cause is that your Layout was not found. I deployed to IIS and (after commenting out the offending line) found that the Layout hadn't been copied during web deploy. In my case, it was because the layout's Build Action had been changed from Content to None.
EDIT: In fact, I had MVC 3 RC installed. The above was just a different symptom. The deployment machine had RTM which exposed the problem. As awrigley says, it's called ViewBag now.

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