2016-08-25 15 views
1

メインMVCプロジェクトで自分のエリアのプロジェクトを別々に設定しています。私はここで、ガイドに従っ:MVC Separate Area Project - ビューを見つけることができません

https://stackoverflow.com/a/12912161/155110

私は打ち上げ時にブレークポイントを設定し、RazorGeneratorMvcStartルートを設定しAreaRegistrationだけでなく、ヒットしていることがわかります。 RazorGenerator.Mvcがインストールされ、cshtmlページのカスタムツールが使用されるように設定されています。私のメインプロジェクトを起動した後、Area URLにアクセスすると、別のAreaプロジェクトでコントローラーに当たることがわかりますが、そのビューを見つけることができません。

[InvalidOperationException: The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:

STARAreaRegistration.cs

using System.Web.Mvc; 

namespace AreaSTAR.Areas.STAR 
{ 
    public class STARAreaRegistration : AreaRegistration 
    { 
     public override string AreaName 
     { 
      get 
      { 
       return "STAR"; 
      } 
     } 

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

RazorGeneratorMvcStart.cs

using System.Web; 
using System.Web.Mvc; 
using System.Web.WebPages; 
using RazorGenerator.Mvc; 

[assembly: WebActivatorEx.PostApplicationStartMethod(typeof(AreaSTAR.RazorGeneratorMvcStart), "Start")] 

namespace AreaSTAR { 
    public static class RazorGeneratorMvcStart { 
     public static void Start() { 
      var engine = new PrecompiledMvcEngine(typeof(RazorGeneratorMvcStart).Assembly) { 
       UsePhysicalViewsIfNewer = HttpContext.Current.Request.IsLocal 
      }; 

      ViewEngines.Engines.Insert(0, engine); 

      // StartPage lookups are done by WebPages. 
      VirtualPathFactoryManager.RegisterVirtualPathFactory(engine); 
     } 
    } 
} 

エリア/ STAR /コントローラ/ DefaultController.cs

:私は場所の膨大なリストを取得し、次の
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Mvc; 

namespace AreaSTAR.Areas.STAR.Controllers 
{ 
    public class DefaultController : Controller 
    { 
     // GET: STAR/Default 
     public ActionResult Index() 
     { 
      return View(); 
     } 
    } 
} 

エリア/ S TAR /ビュー/デフォルト/ Index.cshtml:ビューが見つからないというエラーを見たときにアクセス

@* Generator: MvcView *@ 

@{ 
    Layout = null; 
} 

<!DOCTYPE html> 

<html> 
<head> 
    <meta name="viewport" content="width=device-width" /> 
    <title>View1</title> 
</head> 
<body> 
    <div> 
     Index view 
    </div> 
</body> 
</html> 

URL:http://localhost:53992/STAR/Default/Index

答えて

1

私は誤ってRazorEngine.Generator拡張をインストールし、RazorEngineGeneratorにカスタムツールを設定するため、これがでしたRazer Generator拡張機能をインストールしてカスタムツールをRazorGeneratorに設定する代わりに、

関連する問題