2012-07-03 22 views
0

我們一直在使用mvc webapi beta並試圖升級到rc。升級到mvc4後,在控制器上發現了多個操作rc

我們有以下途徑(唯一的限制是爲了驗證(編號)是一個整數):

"Api Verb with SubAction" api/{controller}/{id}/{action} 
"Api Verb with Id"   api/{controller}/{id} 
"Api Verb without Id"  api/{controller} 
"Api Action with Id"  api/{controller}/{action}/{id} 
"Api Action without Id"  api/{controller}/{action} 

而下面的控制器操作

public IList<PaymentMethodViewModel> GetList() 
{} 

public HttpResponseMessage Get(Guid id) 
{} 

[ActionName("Details")] 
public IList<RecurrenceModel> GetDetails(Guid id) 
{} 

API/myController的,API/myController的/ 1,api/mycontroller/1 /所有細節都在測試版中正確返回。但是,在升級到MVC4 RC api/mycontroller/1之後,api/mycontroller/1/details會返回「找到與請求匹配的多個操作:」

回答

0

是的,我遇到過類似的問題,未能找到正確的原因。這顯然是由於路由實現的變化,但代碼的實現相當沉重,我沒有時間去完成它。

考慮到它將繼續按照這個速度發展,最好的做法是僅依靠內置路由機制來實現路由的默認{controller}/{id}風格,而其他任何方面都需要AttributeRouting

相關問題