开发者

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

开发者 https://www.devze.com 2022-12-26 09:09 出处:网络
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<>(

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 开发者_Python百科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>)'


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 :)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号