Nice programing

Html.ActionLink를 동적으로 전달할 수 없습니다.

nicepro 2020. 12. 29. 08:25
반응형

Html.ActionLink를 동적으로 전달할 수 없습니다.


MVC3에 문제가 있습니다.

@Html.ActionLink()내 블로그 프로젝트의 제목에 대한 링크를 생성하는 데 사용하려고합니다 .

ActionLink작업 에서 상수 문자열을 사용하는 것은 멋지지만 Posts.Title(현재 Post 모델의 제목이 반복됨) 사용하면 다음 예외가 발생합니다.

CS1973: 'System.Web.Mvc.HtmlHelper<dynamic>' has no applicable method 
named 'ActionLink' but appears to have an extension method by that name.  
Extension methods cannot be dynamically dispatched. Consider casting  
the dynamic arguments or calling the extension method without the  
extension method syntax.

"동적 인수를 캐스팅하거나 확장 메소드 구문없이 확장 메소드를 호출하는 것을 고려하십시오."

Posts.Title에는 유형이 없습니다 (따라서 동적 인수).

(string) Posts.Title을 통해 캐스팅하십시오.

참조 URL : https://stackoverflow.com/questions/5832692/html-actionlink-cannot-be-dynamically-dispatched

반응형