문제는, 당신의 HttpPostedFile 함께 유형. 이 템플릿은 Razor에게 템플릿이 구현하는 유형의 속성에 대해 생성해야하는 HTML을 알려줍니다. 면도기는 당신이 오버라이드 할 수있는 두 개의 템플릿을 가지고 있으며 프로젝트에서 볼 수 없지만 HttpPostedFile은 그 중 하나가 아니기 때문에 FileName, ContentType 및 ContentLength가 HttpPostedFile 용으로 렌더링 된 인터페이스로 표시됩니다.
우는 소리는
public abstract class HttpPostedFileBase {
public virtual int ContentLength {
get {
throw new NotImplementedException();
}
}
public virtual string ContentType {
get {
throw new NotImplementedException();
}
}
public virtual string FileName {
get {
throw new NotImplementedException();
}
}
public virtual Stream InputStream {
get {
throw new NotImplementedException();
}
}
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "filename",
Justification = "Matches HttpPostedFile class")]
public virtual void SaveAs(string filename) {
throw new NotImplementedException();
}
}
그 템플릿 중 하나가 디폴트에 없기 때문에, 면도기 클래스를 탐구하고 클래스의 각 공용 속성 편집기를 생성하려고 클래스 HttpPostedFile의 구현입니다. 당신이 부동산을 통해 데이터 형식을 지정하는 경우
[DataType(DataType.SELECTYOURTYPEHERE)]
그런 다음 당신은 예를 들어, 당신은이
[DataType(DataType.Upload)]
public HttpPostedFile myfile { get; set; }
을 할 수
조회/공유/EditorTemplates에 템플릿을 대체 할 수 있습니다
다음에 Upload.cshtml을 만들고 보기/공유/EditorTemplates/Upload.cshtml 을 업로드 용으로 표시하려는 html로 변경하십시오.
희망이이 상황에서 비계에 대한
확실하지 도움이되지만 않습니다 [이 질문] (http://stackoverflow.com/questions/21772153/generate-file-upload-input-for-property-with -datatype-upload-attribute) 도움이 필요하십니까? – stuartd