2012-01-09 16 views
2

この問題の解決策が見つかりません。
私は1つのプロジェクトで2つのMVC3プロジェクトに参加する必要があります。そして、私はそれらを別々のフォルダに置く必要があります。フォルダに入れた後mvcコントローラを別のPARENTフォルダに正しくルーティングするにはどうすればいいですか?

enter image description here

最初のプロジェクト:私が何を意味するかを確認するには、のは、これらの画像を見てみましょう

enter image description here

今、私は私が得たプロジェクトを実行するときこのエラー:

Server Error in '/' Application. 

The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched: 
~/Views/Home/Index.aspx 
~/Views/Home/Index.ascx 
~/Views/Shared/Index.aspx 
~/Views/Shared/Index.ascx 
~/Views/Home/Index.cshtml 
~/Views/Home/Index.vbhtml 
~/Views/Shared/Index.cshtml 
~/Views/Shared/Index.vbhtml 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched: 
~/Views/Home/Index.aspx 
~/Views/Home/Index.ascx 
~/Views/Shared/Index.aspx 
~/Views/Shared/Index.ascx 
~/Views/Home/Index.cshtml 
~/Views/Home/Index.vbhtml 
~/Views/Shared/Index.cshtml 
~/Views/Shared/Index.vbhtml 

Global.asax内側:

namespace MvcApplication1 
{ 
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801 

    public class MvcApplication : System.Web.HttpApplication 
    { 
     public static void RegisterGlobalFilters(GlobalFilterCollection filters) 
     { 
      filters.Add(new HandleErrorAttribute()); 
     } 

     public static void RegisterRoutes(RouteCollection routes) 
     { 
      routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 

      routes.MapRoute(
       "Default", // Route name 
       "{controller}/{action}/{id}", // URL with parameters 
       new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults 
      ); 

     } 

     protected void Application_Start() 
     { 
      AreaRegistration.RegisterAllAreas(); 

      RegisterGlobalFilters(GlobalFilters.Filters); 
      RegisterRoutes(RouteTable.Routes); 
     } 
    } 
} 

質問:

  1. 私のGlobal.asaxの設定がどうあるべきか? (ここから問題が始まると思われます)
  2. 1番の問題が解決できれば、2番目のMVC3プロジェクトのルートをどのようにマップするのですか?

ありがとうございます!!!!

答えて

4

はAsp.net MVC-3

からあなたが最良の両方のURLと出力を制御することができる方法を「エリア」を使用してみてください。

+0

その考えをありがとう。私は今、地域を勉強しています。 – fiberOptics

1

エリアは、MVC3の非常に優れた機能です。このようにルーティングすることができます。 Global.asaxの中

see here

+0

リンクありがとう!実際に私は今それを読んでいる。 – fiberOptics

+0

私の答えを正しいものにするのはどうですか? – IamStalker

0

すでにエリアを登録するかどうかを確認します。

protected void Application_Start() 
    { 
     AreaRegistration.RegisterAllAreas(); 
関連する問題