2012-11-26 25 views
0

我有以下作用:HttpVerbs.Get和參數?

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 = "" } 
      ); 
+0

您定義了哪些路線? – jrummell

+0

用潰敗更新 – Ivy

回答

1

你有feedKey定義的路由?使用默認路由,以下應該工作(更改feedKeyid)。

[AcceptVerbs(HttpVerbs.Get)] 
    public ContentResult Feed(string id) 
    { 
     // ... 
    } 
+0

不錯,謝謝!如果我要創建一條新路線,它將會如何? – Ivy