Inferred actions and ambiguous action matches

12 views
Skip to first unread message

Darren Cauthon

unread,
Aug 9, 2010, 1:20:12 PM8/9/10
to MVC Turbine

In the TurbineActionFilter, there is a try-catch surrounding the
FindAction method call with a note that it's a hack to Turbine to work
under Mono.

http://github.com/lozanotek/mvcturbine/blob/master/src/Engine/MvcTurbine.Web/Controllers/TurbineActionInvoker.cs#L66

What type of Mono error is it causing, and would it be possible for us
to try to catch that error? Or to allow specific and common errors to
go through?

The reason I'm asking is to perhaps save some confusion and time when
it comes to ambiguous action. Here's a situation I and a few
coworkers have gone through:

1.) We TDD-up a controller with two actions that have the same name.
The second takes in an input model.

2.) We create the view.

3.) We run the code, see our form, but the form doesn't work.

4.) We debug the controller, and find that it is *NEVER* called.

5.) We realize that we forgot to put the [HttpPost] attribute on the
second action. We put it on and everything works.

The ambiguous match error that MVC throws is eaten by Turbine, and
since there is a view with a matching name the system uses inferred
actions to present the view. We use the inferred action behavior
elsewhere, but it might be handy if we can expose this and perhaps
some other common errors to keep coders from getting confused.

I want to make this change for us, but without knowing the exact issue
with Mono I don't want to share the change to everybody. Javier, how
do you feel about this and do you remember what the Mono issue was?


Darren

Javier Lozano

unread,
Aug 9, 2010, 2:44:16 PM8/9/10
to MVC Turbine
The error with Mono was with the internal LINQ implementation for
Mono. In the .NET side, if no Action is found by that name, a null
value is returned. In Mono, an exception is thrown by the linq query
against the internal dictionary.

In all reality, we can just capture that specific exception...now to
think of it, now sure why I didn't do that in the first place. My bad :
(

But yes you're right, we should only be catching those specific issues
for this 'action missing' piece on Mono, everything else I say let the
framework bubble up.

Thoughts?


On Aug 9, 12:20 pm, Darren Cauthon <darrencaut...@gmail.com> wrote:
> In the TurbineActionFilter, there is a try-catch surrounding the
> FindAction method call with a note that it's a hack to Turbine to work
> under Mono.
>
> http://github.com/lozanotek/mvcturbine/blob/master/src/Engine/MvcTurb...

Darren Cauthon

unread,
Aug 10, 2010, 10:36:41 PM8/10/10
to mvctu...@googlegroups.com

I think trapping just that error and letting the rest bubble up is a fine idea, sometime in the future.  I like that better than only letting specific errors bubble up.  I don't know what error was throwing, though, so I'll have to leave that to you to look at. :)

Thanks!


Darren Cauthon
dar...@cauthon.com
(913) 712-9648

Javier Lozano

unread,
Aug 10, 2010, 10:39:59 PM8/10/10
to MVC Turbine
Yep, I figured I would add that to the list :)

On Aug 10, 9:36 pm, Darren Cauthon <dar...@cauthon.com> wrote:
> I think trapping just that error and letting the rest bubble up is a fine
> idea, sometime in the future.  I like that better than only letting specific
> errors bubble up.  I don't know what error was throwing, though, so I'll
> have to leave that to you to look at. :)
>
> Thanks!
>
> Darren Cauthon
> dar...@cauthon.com(913) 712-9648
Reply all
Reply to author
Forward
0 new messages