質問

私のルートは次のようになります:

  routes.Add(new Route("{companyName}/{action}/{id}", new MvcRouteHandler())
   {
     Defaults = new RouteValueDictionary(new { controller = "CompanyController", action = "Index", id = 1 }),
   }   
   );

私のアクション:

  public ActionResult Index(string companyName, string id)
  {
         Response.Write(companyName);
         Response.End();

         return ViePage("~/views/company/index.aspx");
  }
役に立ちましたか?

解決

これを試してください:

 routes.Add(new Route("{companyName}/{action}/{id}", new MvcRouteHandler())
   {
     Defaults = new RouteValueDictionary(new { controller = "Company", action = "Index", id = 1 }),
   }   
   );

コントローラーを参照するとき、「コントローラー」を持ちたくない名前の一部。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top