UFO ET IT

'색인'보기 또는 해당 마스터를 찾을 수 없습니다.

ufoet 2020. 12. 15. 19:33
반응형

'색인'보기 또는 해당 마스터를 찾을 수 없습니다.


The view 'Index' or its master was not found. The following locations were searched:
~/Views/ControllerName/Index.aspx
~/Views/ControllerName/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx

ASP.Net mvc 영역을 사용할 때이 오류가 발생했습니다. 영역 컨트롤러 작업이 호출되지만 영역보기 폴더 대신 '기본'프로젝트보기에서보기를 찾는 것 같습니다.


해야 할 일은 지역 이름에 토큰을 설정하는 것입니다.

예를 들면 :

context.MapRoute(
        "SomeArea_default",
        "SomeArea/{controller}/{action}/{id}",
        new { controller = "SomeController", action = "Index", id = UrlParameter.Optional }
    ).DataTokens.Add("area", "YOURAREANAME");

이 오류는 Controller 메서드 이름이 View의 이름과 동일하지 않기 때문에 발생했습니다.

컨트롤러 방법을 마우스 오른쪽 버튼으로 클릭하고보기로 이동 (Ctrl + M, Ctrl + G)을 선택하면보기가 열리거나 (성공) 하나를 찾을 수 없다고 불평합니다 (보고있는 내용).

  1. 해당 컨트롤러 및보기 폴더 이름은 동일한 이름을 갖습니다.
  2. 해당 컨트롤러 메소드 및 뷰 페이지는 동일한 이름을 가져야합니다.
  3. 메서드 이름이 뷰 이름과 다른 경우 return view("viewName")메서드에서.

Global.asax 파일에는 URL 경로가 포함되어 있습니다. 이와 같은 기본 URL 경로.

"{controller}/{action}/{id}"

그래서, 이것을 시도하십시오.

1. 아래와 같이 컨트롤러 방법을 마우스 오른쪽 버튼으로 클릭합니다.

예 : 메소드를 호출한다고 가정 해 보겠습니다 Index().여기에 이미지 설명 입력

2. Add View ..를 클릭하고 적절한 이름을 지정합니다.이 예제에서 이름은 Index 여야합니다.

여기에 이미지 설명 입력

그런 다음 관련 폴더 구조로 생성하여 올바른보기를 추가합니다.


MyArea AreaRegistration.cs 에서 생성 된 코드를 확인하고 컨트롤러 매개 변수가 기본 컨트롤러로 설정되어 있는지 확인합니다. 그렇지 않으면 컨트롤러가 어떤 이유로 봇으로 호출됩니다. ASP.NET MVC는 영역 폴더에서 뷰를 검색하지 않습니다.

public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "SomeArea_default",
            "SomeArea/{controller}/{action}/{id}",
            new { controller = "SomeController", action = "Index", id = UrlParameter.Optional }
        );
    }

이 오류는 웹 서버에 배포 된 경우에만 발생하는 경우보기가 올바르게 배포되지 않았기 때문에 문제가 발생할 수 있습니다.

An example of how this can happen is if the build action for the views is set to None rather than Content.

A way to check that the views are deployed correctly is to navigate to the physical path for the site on the web server and confirm that the views are present.


The problem was that I used MvcRoute.MappUrl from MvcContrib to route the context.Routes.

It seems that MvcContrib routing mapper was uncomfortable with area routing.


You most likely did not create your own view engine.
The default view engine looks for the views in ~/Views/[Controller]/ and ~/Views/Shared/.

You need to create your own view engine to make sure the views are searched in area views folder.

Take a look this post by Phil Haack.


I had this problem today with a simple out of the box VS 2013 MVC 5 project deployed manually to my local instance of IIS on Windows 8. It turned out that the App Pool being used did not have the proper access to the application (folders, etc.). After resetting my App Pool identity, it worked fine.


  1. right click in index() method from your controller
  2. then click on goto view

if this action open index.cshtml?

Your problem is the IIS pool is not have permission to access the physical path of the view.

you can test it by giving permission. for example :- go to c:\inetpub\wwwroot\yourweb then right click on yourweb folder -> property ->security and add group name everyone and allow full control to your site . hope this fix your problem.


It´s still a problem on the Final release.. .when you create the Area from context menu/Add/Area, visual studio dont put the Controller inside de last argument of the MapRoute method. You need to take care of it, and in my case, I have to put it manually every time I create a new Area.


You can get this error even with all the correct MapRoutes in your area registration. Try adding this line to your controller action:

If Not ControllerContext.RouteData.DataTokens.ContainsKey("area") Then
    ControllerContext.RouteData.DataTokens.Add("area", "MyAreaName")
End If

If You can get this error even with all the correct MapRoutes in your area registration and all other basic configurations are fine.

This is the situation:

I have used below mentioned code from Jquery file to post back data and then load a view from controller action method.

$.post("/Customers/ReturnRetailOnlySales", {petKey: '<%: Model.PetKey %>'}); 

Above jQuery code I didn't mentioned success callback function. What was happened there is after finishing a post back scenario on action method, without routing to my expected view it came back to Jquery side and gave view not found error as above.

Then I gave a solution like below and its working without any problem.

 $.post("/Customers/ReturnRetailOnlySales", {petKey: '<%: Model.PetKey %>'},
      function (data) {
 var url = Sys.Url.route('PetDetail', { action: "ReturnRetailOnlySalesItems", controller: "Customers",petKey: '<%: Model.PetKey %>'});
 window.location = url;});   

Note: I sent my request inside the success callback function to my expected views action method.Then view engine found a relevant area's view file and load correctly.


I have had this problem too; I noticed that I missed to include the view page inside the folder that's name is same with the controller.

Controller: adminController View->Admin->view1.cshtml

(It was View->view1.cshtml)(there was no folder: Admin)


이 오류는 MSI 설치 프로그램이 실제로 파일을 배포하지 못한 경우에도 나타날 수 있습니다.

필자의 경우 .aspx 파일을 .cshtml 파일로 변환하고 Visual Studio는 이것이 새로운 파일이라고 생각하고 빌드 작업을 콘텐츠 대신 없음으로 설정했기 때문에 발생했습니다.


여기에서 같은 문제가 발생했습니다. csproj의 xml 구조를 살펴보면 Content 노드 (ItemGroup 노드 내부)가 "없음"이라는 것을 알았습니다. 그 이유는 확실하지 않지만 그 이유가 바로 그 때문입니다. 같은 오류가 발생하여 다른 오류와 마찬가지로 "콘텐츠"로 편집하고 작동 중입니다.

도움이되는 희망

참조 URL : https://stackoverflow.com/questions/2269220/the-view-index-or-its-master-was-not-found

반응형