ASP.NET MVC 핵심 프로젝트를 만들고보기를 검색 할 사용자 정의 폴더를 등록했습니다. *Azure에 게시 한 후보기를 찾을 수 없습니다.
MyViewLocation/A/조회수 내부public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.Configure<RazorViewEngineOptions>(options =>
{
options.ViewLocationExpanders.Add(new AppsViewLocationExpander());
});
}
폴더 일부 이다 : 나는 IViewLocationExpander
클래스 같은 사용자 지정으로 이런 짓을 :
public class AppsViewLocationExpander : IViewLocationExpander
{
public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context,
IEnumerable<string> viewLocations)
{
yield return "/MyViewLocation/A/Views";
//and so on...
}
그리고 에 Startup.cs이 클래스를 사용 .cshtml 파일 및 로컬 디버그 세션 오류없이 진행. 이제 Azure에 웹 응용 프로그램을 게시하고 500 Internal Server Error가 발생했습니다. 이 오류를 디버깅하기 위해 Visual Studio를 첨부하고 다음 메시지가 나타납니다.
System.InvalidOperationException : 'Index'보기를 찾을 수 없습니다. 다음 위치가 검색되었습니다 :
/MyViewLocation/A/Views/Index.cshtml 내가 뭘 잘못했는지
를? Views-Folder를 다른 장소에도 추가해야합니까?
편집는 :
나는 나의 초기 설정에서 내 project.json를 수정, 그러나 이것은 내 푸른 문제에 도움이되지 않습니다. 그러나 아마도 내 로컬 디버깅 중에 뷰를 찾는 것이 필요했습니다.
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"MyViewLocation/**/Views",
"appsettings.json",
"web.config"
]
},
편집 2 :
은 내가 FTP 서버에 수동으로 * .cshtml 파일을 업로드했습니다. 그럼에도 불구하고 그들은 아직도 발견되지 않습니다.
보기 파일이 웹 응용 프로그램에 배포되었거나 없습니까? – DavidG
@DavidG FTP에서 파일을 찾을 수 없으므로 파일이 누락되었다고 생각합니다. 배포 스크립트를 수정해야합니까? – Koopakiller
뷰 파일에 대한 'Build Action'은 무엇입니까? (즉, Visual Studio의 파일 속성에 있음) – DavidG