ASP.NET MVC 出現錯誤 “The view 'XXX' or its master was not found or no view engine support”

來源:互聯網
上載者:User

標籤:style   http   color   io   os   ar   sp   檔案   on   

來自:http://www.dengyukeji.com/archiver/tid-151.html

 錯誤如下:The view ‘XXX‘ or its master was not found or no view engine supports the searched locations.

The following locations were searched:
~/Views/XXX/XXX.aspx
~/Views/XXX/XXX.ascx
~/Views/Shared/XXX.aspx
~/Views/Shared/XXX.ascx
~/Views/XXX/XXX.cshtml
~/Views/XXX/XXX.vbhtml
~/Views/Shared/hotgoodslist.cshtml
~/Views/Shared/hotgoodslist.vbhtml網上比較少這些資料;
但是你總找不到原因,其實原因很簡單,就是因為你的這個路由地址找不到了。The following locations were searched:
~/Views/XXX/XXX.aspx
~/Views/XXX/XXX.ascx
~/Views/Shared/XXX.aspx
~/Views/Shared/XXX.ascx
~/Views/XXX/XXX.cshtml
~/Views/XXX/XXX.vbhtml
~/Views/Shared/hotgoodslist.cshtml
~/Views/Shared/hotgoodslist.vbhtml這些代碼的意思就是說以下的這些項會被搜尋,所有的請求都會按下面的地址進行查詢搜尋,直到找到匹配的為止,報這個錯,就是因為你的路由中在你的View檔案夾中找不到了。
解決方案:
首要檢查的就是你的View跟你寫的路由地址的Action名稱是否一致。
我要在做項目的時候就是因為這個名稱不一致導致的,比如我的路徑是/XXXX/XXXXManager/XXXCreate
但是我實際的View中的檔案名稱是XXXCraete。說實話這個問題是很難查的。
不過教大家一個方法:~/Views/XXX/XXX.aspx
~/Views/XXX/XXX.ascx
~/Views/Shared/XXX.aspx
~/Views/Shared/XXX.ascx
~/Views/XXX/XXX.cshtml
~/Views/XXX/XXX.vbhtml
~/Views/Shared/hotgoodslist.cshtml
~/Views/Shared/hotgoodslist.vbhtml就是按照這個地址去你的View檔案夾裡面找一遍,看看是不是由於不致導致的,就可以了。
其實要檢查的就是你的路由配置沒寫好。這個我還沒碰到過,有碰到過的朋友請告訴我。

今天把項目發布IIS的時候,出現這個問題,解決方案 :/Views/XXX/下缺少XXX.cshtml檔案,直接把電腦上的XXX.cshtml檔案拷貝到IIS的下面就可以了。

ASP.NET MVC 出現錯誤 “The view 'XXX' or its master was not found or no view engine support”

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.