Single Action Controllers and ReSharper's Solution-Wide Analysis - asp.net-mvc-3

We've got an ASP.NET MVC 3 project that uses single action controllers, and ReSharper doesn't like it. For example:
#using (Html.BeginForm("DoRegister", "Account")) {
It doesn't like either DoRegister or Account, because it's looking for a class AccountController with an action DoRegister. What we've actually got is a folder Controllers\Account, with a single-action class DoRegister.
Can I teach ReSharper about this? If not, can I get it to ignore this particular pattern?
I know that I can right-click and Ignore Errors in the Errors in Solution window, but this only lasts until I pull an updated version of the code from source control, which gets annoying quite quickly.

I am afraid ReSharper supports only default MVC convention.
But you can disable MVC analysis:
At All
ReSharper->Options->ASP.NET->Other->Enable ASP.NET MVC references
On all unknown action and controller errors
Alt+Enter on error, Inspection Options for "Unknown Symbol"
At that specific place
Again, Alt+Enter on error, Supress Inspection "Unknown Symbol" with comment.

Related

MVC 5 Razor view displays Linq errors but page renders correctly

I frequently get errors such as displayed in the picture below when using Linq in a Razor view. I have obviously added the #using System.Linq include on the top of the page (although it will strangely work without it), but still get the errors no matter what i try.
Is there any way to prevent these errors from appearing? I know i shouldn't be using too much code inside a view, perhaps the best solution would be to build the list in the code, use it here and stop worrying about editor syntax errors?
Razor Linq Error
This kind of problems is often in some way related to the config files. Have you seen this answer?
The type 'IEnumerable<>' is defined in an assembly that is not referenced
You can also try to create a test project and see if everything works as expected there and if it does, compare the web config files for possible differences... Note that there are two of those in each mvc project...

InResharper 2016.2 MVC specific feature is not visible/working

I have updated my resharper version to 2016.2 from 2016.1 (on visual studio 2015),
Suddenly it stops showing some the very often used feature specific to MVC like, hint for add view(which doesn't exists) for a action method in a controller, it is not even highlighting a navigation link for a return View();
Even very less information provided in documentation here
Also it is not highlighting hint error message for missing View file for a action method in controller.
Any hint to solve this issue is appreciated in advance. Problem Image
Expected to work as below (taken from documentation url mentioned above):

Telerik problems with IntelliSense and Templates

I am working on the project where I use Telerik MVC controls in order to show some NumericTextBoxes and other controls. I have two problems that are maybe related.
1/ IntelliSense works fine in Views/Shared and in some Views. But in some it doesn´t work. The code is absolutely similar without specific blocks of code. I try to add all Telerik namespaces to Web.Config in Views folder, but it doesn´t work. Just in Views/Shared is IntelliSense working.
2/ I would like to use [SourceCodeFile] attribute in my Controller in order to using NumericTextBoxes templates. But VS says "Unknown attribute" and "Resolve" is not in context menu. I was trying to add all Telerik namespaces but it still doesn´t work.
Some suggestions?

ASP.NET MVC Add View Dialog closing

Recently a large project I work on started having a problem with the Add View dialog. When clicking the Add Strongly-typed View checkbox, the spinner comes up the first time for about a second or two, and then the entire dialog just closes and disappears. If I open the dialog and click the button again, it just closes again quickly.
The project is using ASP.NET MVC 2, I have installed VS2010 SP1 and this problem occurs with or without the MVC3 tools update installed. It only happens with this project, and I have replicated the problem on 2 different development machines. If I create a new MVC2 or MVC3 project, this does not happen at all, nor do any other small to medium sized projects I have.
I can of create a regular view and change it to strongly typed by myself, so there is a workaround, but this is still pretty annoying. Any ideas what could be causing this or how to fix it?
Do you use version control? Make sure all the assemblies that your project depends on (i.e. referenced by the project itself or by its referenced assemblies) are in sync. I've just run into this (both "Add View" and "Add Controller" problems) after updating a bunch of projects from SVN and rebuilding some. The issue was fixed after I rebuilt several libraries that my MVC project depends on.
I had the same problem, and I could not open the Add->Controller dialog either as described here: Add Controller after recent tools update fails with dependency error. In my case, I had added models to my domain, but I had forgotten to add contexts for these new models; things like
public DbSet<Region> Regions { get; set; }
I had no error at compile time, and I was not using these models yes in the solution, so there was no error at run time either. I guess the problem can be anywhere though.

mvc html.serialize to store model in view

Can anyone tell me what happened to the Html.Serialize function mentioned in the url below.
It's not recognized when I try and use it in a MVC2 web app within Visual Studio 2010.
http://weblogs.asp.net/shijuvarghese/archive/2010/03/06/persisting-model-state-in-asp-net-mvc-using-html-serialize.aspx
EDIT - I'm using visual studio 2010 which comes with mvc2 'built in' when i try and use Html.serialize on a view or partial view it's not appearing in intellisense. Am i missing a reference or something?
It hasn't gone anywhere. It is right there, wherever you are able to use the html extensions. Eg, Views, PartialViews.
For example:
<%= Html.Serialize("wizardData", Model)%>
Are you trying to use it in a controller? To use it as shown in the article you quote, you need to use it in a view.
You see, we really don't know because you haven't given us any detail to work with. Show us some code, and we will move your earth. Well, try to anyway.
I see you are new, so when asking questions, try to give as much detail as possible. You can edit your post, just mark out what you have done. The more context we get, the more we can help.
I found out why! I was having similar problems too.
You need to download ASP.NET 2 Futures and use the DLLs provided there instead of the usual Mvc DLL.
It is implemented in SerializationExtensions class.
It's in the MVCFutures assembly and not part of the out the box MVC framework. You will need to add the package via nuget or manual download and then add a using/imports statement to Microsoft.Web.Mvc before you can use it in your view.

Resources