ASP.NET MVC2 - Resolve Parameter Attribute in Model Binder
-
23-09-2019 - |
문제
Given an action like:
public ActionResult DoStuff([CustomAttribute("foo")]string value) {
// ...
}
Is there any way to resolve the instance of value
's CustomAttribute
within a ModelBinder? I was looking at the MVC sources and chances are I'm just doing it wrong, but when I tried to replicate their code which retrieves the BindAttribute for a complex model, calling GetAttributes() did not return the attribute I am looking for.
DefaultModelBinder
GetTypeDescriptor(controllerContext, bindingContext).GetAttributes();
해결책
토론 보드에는 토론 및 메시지의 두 가지 콘텐츠 유형이 있습니다. 토론은 높은 수준의 콘텐츠 유형이며, 메시지는 모든 답변입니다. "State"또는 "Status"필드를 추가하거나 토론 콘텐츠 유형에 추가하면 응답이 아닌 질문에만 적용됩니다.
- 상태라는 사이트 열을 만들고 원하는 값을 지정하십시오.
- 토론 보드를 만듭니다.
- 토론 보드의 설정 및 콘텐츠 유형 토론을 클릭합니다. 를 클릭하십시오.
- 상태 사이트 열을 추가합니다.
사용자가 새 질문을 만드는 경우 해당 상태가 첨부 된 목록의 유일한 항목만이 질문이됩니다.
답변은 본문만을 가지고 있습니다.
제휴하지 않습니다 StackOverflow