BC30451: 'ViewData' is not declared - error on server - asp.net-mvc

My MVC 3 project is building successfully in my development machine with Visual Studio 2010 + MVC 3.
Last night I deployed a routine update to the live server for my MVC website. It was working fine on dev, but on deployment the entire site fell over with a "system.web.mvc" could not be found.
After a bit of research I tried setting my reference to system.web.mvc.dll to "Copy Local". On deployment, this partially solved the problem, but now I get the following error on accessing the site:
BC30451: 'ViewData' is not declared
The ViewData is the first code reference on the page, so it would seem that system.web.mvc is somehow not accessible from the vbhtml file, despite having "fixed" the first error.
Struggling to find any reference to this problem on line, so any assistance much appreciated.

You should use special mechanism for bin deployment of MVC 3.
Just right click on the project and select Add Deployable Assemblies and you’ll see the following .
Check first and click ok.
For more information you can read this link

Related

The name 'Url' does not exist in the current context error VS2017

Getting an error The name 'Url' does not exist in the current context error in asp.net whenever I open a .cshtml file in my web project.
I should note that I got this solution fresh from our source repo and other developers tell me they don't see this issue.
Web project has a referenced to a nuget package and when I look at System.Web.MVC it's Mvc.4.0.40804
Things I've tried based on posted solutions:
1) Unloaded project and deleted .user file and did a clean and rebuilt.
2) Deleted temp ASP files in the .net framework directory.
There are a lot of other solutions saying to move views or adding to web.config file, but if other developers using same solution aren't facing this - I'm thinking it's machine specific.
I don't see any reference errors in the web project.
When I installed VS2017, I just did the ASP.NET development. So, i have no gotten another version of MVC. Could it be that?
Thanks,
Brian
So I ended up modifying my VS2017 install and under ASP.NET and web development, I uninstalled that and reinstalled and made sure ASP.NET MVC 4 was checked off under Optional.

NuGet error on site build & custom namespaces not seen by the project

I installed Umbraco 7 using NuGet package in my VS (following this tutorial: http://www.systenics.com/blog/setting-up-umbraco-7-in-visual-studio-2013-for-mvc-4-development/).
I now have 2 problems:
1.
Now I'm getting error on every rebuild:
An error occurred loading a configuration file: Directory 'C:\inetpub\wwwroot\mvcimport\app_data\nugetbackup\20140707-140849\config' does not exist. Failed to start monitoring file changes. C:\inetpub\wwwroot\mvcimport\App_Data\NuGetBackup\20140707-140849
(line 1 in \Web.config)
The error doesn't occur only on first build after I close the solution and reopen it.
2.
I added my models but the view doesn't see it. Neither controller I added doesn't see my custom namespaces - as you can see on the image MvcImport sees only Controlles namespace which is the one I;m typing in.
Even though (except the case above) the project compiles without error.
And when the error (1) occurs on compilation then a number of errors appear also eg.
The type or namespace name 'Models' does not exist in the namespace 'MvcImport' (are you missing an assembly reference?) C:\inetpub\wwwroot\mvcimport\Controllers\ImportController.cs
I can't see how I'm supposed to add my own assemblies if not by simply compiling the project?
I have deleted and recreated the project for the 5th or 6th time now.
Finally it worked (fingers crossed no more problems).
In case someone else needs it I did the following:
New project
In the New project window selected Installed > Templates > Web > Visual Studio 2012 from the left hand side, .NET Framework 4.5 from the top dropdown and ASP.NET MVC 4 Web Application from the project type list then clicked ok
On the following screen selected Empty application then clicked OK.
Right clicked the project in Solution Explorer, clicked NuGet console, found Umbraco Cms, installed it (you can also install from the package manager console - more here http://www.systenics.com/blog/setting-up-umbraco-7-in-visual-studio-2013-for-mvc-4-development/)
Clicked F5 to debug, inserted my cms access details, clicked Customise button at the bottom and added my database connection data.
This tutorial is also helpful http://our.umbraco.org/documentation/Installation/install-umbraco-with-nuget.
Important is when you install in the VS2013 instead of Web > ASP.NET Web Application choose Web > Visual Studio 2012 > ASP.NET MVC 4 Web Application in point 2 above - this made the difference and allowed me to create the project without errors eventually.

MVC 2 to MVC 3: MvcScaffolding fails due to "could not load file or assembly" error

Setup:
I am using MVC 3, EF 4.1, Visual Studio 2010 SP1 with Power Tools updated to latest version.
With the above installations, I don't need the NuGet packages that were required previously. Everything is RTM.
The project has been upgraded from MVC 2 to MVC 3. I initially tried the upgrade tool, but that gave me grief, so I did it manually as per the instructions in the MVC 3 Read Me file.
Problem:
When trying to use the new scaffolding of controllers and views for CRUD functionality (against Code First DbContext), the scaffolding fails with the error:
Could not load file or assembly 'file:///C:\[PATH TO MY APP]\bin\Lanap.BotDetect.dll'
or one of its dependencies. Operation is not supported.
(Exception from HRESULT: 0x80131515)
Question:
Lanap.BotDetect is a Captcha control. It works fine and is there, I use it in other pages no problems, the solution compiles, etc, etc. So there is no problem with this dll.
However, this error is stopping me using the new scaffolding capabilities.
I can't see what it has to do with the scaffolding of a new controller and its views, so there must be some configuration that is wrong.
Any suggestions as to where I can look? Googling has drawn a blank.
EDIT 1:
I am trying to see the failed assembly binding using Fusion Log as suggested in a comment. No failed binding showing (but that might be my fault) but the question remains:
Why would MvcScaffolding NEED to load the Captcha .dll at all? It is just scaffolding a controller, and nothing in the T4 says anything about this .dll
(NOTE: I haven't edited the scaffolding T4 code)
EDIT 2:
I tried removing the reference to Lanap.BotDetect, and the error changed to not being able to open the config file that has the connection strings (I shunt the connection strings out to a db.config string, just gives me less visual pain when looking at a config file).
I am giving up on scaffolding on this app. It works in clean, new apps, but not this one where there is a lot of pre existing code.
I found another solution to this. Turns the issue for me was that the issue was it was being built over a network drive. So when I moved the project over to a location local to my machine and rebuilt the project it corrected everything. I detailed everything with screen shots and here...
http://ryandunn.co/mvc-growing-pains-could-not-load-file-controller-dll
Put simply check the location of your project and move it to C: after that a quick rebuild had me back and working normally.
So I know that you have moved on but I ran into the same problem and just found the solution. It turns out the error is due to the assembly not being trusted i.e. you downloaded it from the internet.
You can right click the .dll and unblock it to fix the problem. For info on how to unblock see the following
http://blogs.msdn.com/b/brada/archive/2009/12/11/visual-studio-project-sample-loading-error-assembly-could-not-be-loaded-and-will-be-ignored-could-not-load-file-or-assembly-or-one-of-its-dependencies-operation-is-not-supported-exception-from-hresult-0x80131515.aspx

MVC 3 Views not deployed

I have been working on a small project on recent delived ASP.NET MVC 3 RC. The issue is that when I try to deploy my website via File System, certain views of my website are not deployed. The site gives me error when i copy same deployed site to my hosting. When I manually copy views to hosting, it works ok.
Now this thing is not breaking anything as such, just want to know that if I am missing something while deploying my site. I am not sure why few views are deployed and why not others. Seems very random to me.
Thanks,
If you created the app before RC (aka using our Beta) we had a bug in which we didn't mark the views as "Content". New apps using the RC have this bug fixed, but if you open an existing project, it doesn't automatically fix up the existing files.
To fix them, select the file and in the properties pane, set the Build Output to "Content".

How to fix the error 'System.Web.Mvc.Controller' is not defined

I started out this morning working with my ASP.NET MVC project like normal and everything worked. I added a new class and some functions and it still worked. Then, all of a sudden, while I was working with a javascript file, I started getting these not defined errors on the MVC classes/functions. There are 118 of them in the project and I'm not sure how to fix them.
I've tried restarting Visual Studio and rebooting the computer. I've also tried loading another MVC project to see if the framework might be hosed, and it works fine. I've checked the references and the ASP.NET MVC 1.0 RC2 dll is there.
Has anyone else ran into this problem?
Please help!
I figured it out. I had added a new Master page to the project, but when did so, I had chosen a regular Master Page not the MVC Master Page. What threw me was that I was able to build the program a couple times and run it after I had done this without seeing any errors.

Resources