0

我有以下行动:

public class IntegrationController : Controller
    {
        [AcceptVerbs(HttpVerbs.Get)]
        public ContentResult Feed(string feedKey)
        {
           ...
        }
}

我曾尝试使用此网址:

http://MyServer/Integration/Feed/MyTest 

但是feedKey是空的吗?这与路线有关吗?

编辑 1:

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

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

            routes.MapRoute(
                "TreeEditing", // Route name
                "{controller}/{action}/{name}/{id}", // URL with parameters
                new { controller = "AdCategory", action = "Add", name = string.Empty, id = -1 }
            );

编辑 2:

routes.MapRoute(
                "IntegrationFeed", // Route name
                "{controller}/{action}/{name}/{feedKey}", // URL with parameters
                new { controller = "Integration", action = "Feed", name = string.Empty, feedKey = "" }
            );
4

1 回答 1

1

你有为 定义的路线feedKey吗?使用默认路由,以下应该可以工作(更改feedKeyid)。

    [AcceptVerbs(HttpVerbs.Get)]
    public ContentResult Feed(string id)
    {
       // ...
    }
于 2012-11-26T18:15:38.807 回答