mare
mare

Reputation: 13083

ASP.NET MVC Futures 2 and MVCContrib 2 in the same web app / project

I have referenced both Microsoft.Web.Mvc.dll (MVC Futures 2) and MVCContrib.dll (from MVC Contrib 2), both current releases from Codeplex and I have a problem with strongly-typed RedirecToAction<>() function of Controller.

It worked fine until I referenced Futures 2..

This is the compile time error. Apparently this function is implemented in both assemblies. How can I resolve that?

Error 1 The call is ambiguous between the following methods or properties: 'Microsoft.Web.Mvc.ControllerExtensions.RedirectToAction(System.Web.Mvc.Controller, System.Linq.Expressions.Expression>)' and 'MvcContrib.ControllerExtensions.RedirectToAction(System.Web.Mvc.Controller, System.Linq.Expressions.Expression>)'

Upvotes: 1

Views: 607

Answers (2)

St&#233;phane
St&#233;phane

Reputation: 11864

To complete Lucero answer,
If that seems a big drawback to you to use the fully qualified name (not very elegant), you can set a shorter alias to the namespace:

using MvcContrib;
using Future = Microsoft.Web.Mvc.ControllerExtensions; 

you can then write it Future.RedirectToAction() or just

RedirectToAction();

if you want to use the one from MvcContrib.

Of course you could just reverse this if you want to use primarily the futures assembly or the alternative to use the Contrib.

Hope this helps :)

Upvotes: 4

Lucero
Lucero

Reputation: 60190

Use the fully qualified name you want to use, e.g. Microsoft.Web.Mvc.ControllerExtensions.RedirectToAction() so that the compiler knows which one you want to call.

Upvotes: 1

Related Questions