URLバーの名前を複製する方法。たとえば、私はとを持っproducts controllerていindex methodます。今私のプロジェクトでは、私はのように実行していlocalhost:89733/Products/Indexます。しかしProducts/Index、同じものを実行するために別の名前を付けたいものの代わりにaction method。どうやってやるの。自分のコントローラー情報を他人に漏らしたくないということです。どんな助けでも大歓迎です。
2 に答える
2
カスタムルートを構成できます。
routes.MapRoute(
"ProductsRoute",
"mycustomproductsname/{id}",
new { controller = "Products", action = "Index", id = UrlParameter.Optional }
);
これで、に移動すると、コントローラーmycustomproductsname/123のIndexアクションProductsが実行され、パラメーターとして123が渡されidます。
于 2012-12-13T07:04:43.757 に答える
0
iルーティングがGlobal.asaxファイルのアプリケーション開始イベントの目的を解決できることを願っています
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RegisterRoutes(RouteTable.Routes);
}
public void RegisterRoutes(RouteCollection routes)
{
//Treeview routing
routes.MapPageRoute("Home", "User/Dashboard", "~/Products/Index");
routes.MapPageRoute("SearchCustomer", "User/Search-Customer", "~/Products/SearchCustomer");
}
私はあなたがこれを求めていて、それがあなたを助けることを願っています
于 2012-12-13T06:04:44.300 に答える