0

コントローラーのアクションがあります

    public string Index(string id)
    {
        return id;
    }

Global.asax.csにはこのルートしかありません

routes.MapRoute(
            "Default", 
            "{id}", 
            new { controller = "Start", action = "Index", id = UrlParameter.Optional }              
        );

この「http:// localhost / stuff」や「http:// localhost/hello」のようなURLの場合は機能します。ただし、「http:// localhost / stuff/add」のようなURLでは機能しません。どうすれば修正できますか?

4

1 に答える 1

2

IDの前にワイルドカード(アスタリスク)を追加します。

     routes.MapRoute(
            "Default",
            "{*id}",
            new {controller = "Start", action = "Index", id = UrlParameter.Optional}
            );
于 2012-10-14T22:19:09.497 に答える