Integration with ASP.NET MVC 2 in case controllers are not in the same project as views

Hi,

In R# 5.0.1528.21 I see a new quick fix (red bulb) in MVC Views to "Add missed controller".

That is very cool, but I actually have controller, it is just in separate projects in the same solution. How do you plan to handle this scenario? Or do I miss something in current version?

I understand that loose coupling between controllers and views makes it rather difficult to find corresponding Views and Controllers. Controllers do not reference Views, or the whole web project, at all, they just produce ViewModel and then conventions look for appropriate view. Views also do not usually know about controllers.

In my case I have a reference from web.config to the project with controllers:

<add namespace="Myproject.Controllers"/>


so strongly-typed lambda-based methods work:

Html.BuildUrlFromExpression<QueueController>(c => c.Queue())


Maybe it is an option to use these kind of hints in the future?

If this scenario is just not supported, it'd be nice to be able to turn of these "Add missed controller" warnings completely.

4 comments
Comment actions Permalink

Hi Alexander!

]]>


so strongly-typed lambda-based methods work:

(c => c.Queue())]]>


Maybe it is an option to use these kind of hints in the future?


Just reference assembly with controllers is not enough.
Standard Controller Factory is finding controllers exactly inside Controllers folder.
Do you use some IoC engine or something else with alternative controller factory?

If this scenario is just not supported, it'd be nice to be able to turn of these "Add missed controller" warnings completely.


Yep, MVC highlightings and Quick Fixes work only for standard layout.
There will be additional check for that condition in next public available build.
Nothing will be shown for non-standard case.

0
Comment actions Permalink

Hi Alexander!

In R# 5.0.1528.21 I see a new quick fix (red bulb) in MVC Views to "Add missed controller".


That is very cool, but I actually have controller, it is just in separate projects in the same solution. How do you plan to handle this scenario? Or do I miss something in current version?

I understand that loose coupling between controllers and views makes it rather difficult to find corresponding Views and Controllers. Controllers do not reference Views, or the whole web project, at all, they just produce ViewModel and then conventions look for appropriate view. Views also do not usually know about controllers.

In my case I have a reference from web.config to the project with controllers:

<add namespace="Myproject.Controllers"/>


Just reference assembly with controllers is not enough.
Standard Controller Factory is finding controllers exactly inside Controllers folder.
Do you use some IoC engine or something else with alternative controller factory?

If this scenario is just not supported, it'd be nice to be able to turn of these "Add missed controller" warnings completely.

Yep, MVC highlightings and Quick Fixes work only for standard layout.
There will be additional check for that condition in next public available build.
Nothing will be shown for non-standard case.

0
Comment actions Permalink

Hi Slava,
Спасибо за быстрый ответ

I use DefaultControllerFactory, did not change it. Did not change Global.asax at all.
Actually I believe standard controller factory is serving all classes that inherit from System.Web.Mvc.Controller, without limiting their assembly or namespace. Cannot find a link about it at the moment, so maybe I am wrong.

That reference in web.config that I mentioned does not play any part in controller resolution process, of course. I only use it to be able to reference Controllers from Views in lambda-expressions without having to write

<%@ Import Namespace="Myproject.Controllers" %>

in every aspx page. So it is not relevant to the question in the end.

Maybe you could extend this feature to recognise all classes implementing System.Web.Mvc.IController? Even if just for 'Create action' part, because for 'Create controller' it would be more difficult.

Just disabling it for nonstandard layout is also ok of course.

0
Comment actions Permalink

Hi.

I would like to know if the feature of having different projects for each MVC concept (Models, Views, Controllers) is planned. Also if there is a way of specifying not only the project, but also a folder.

Thanks in advance.

0

Please sign in to leave a comment.