首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >HttpVerbs.Get和参数?

HttpVerbs.Get和参数?
EN

Stack Overflow用户
提问于 2012-11-27 02:13:15
回答 1查看 411关注 0票数 0

我有以下操作:

代码语言:javascript
复制
public class IntegrationController : Controller
    {
        [AcceptVerbs(HttpVerbs.Get)]
        public ContentResult Feed(string feedKey)
        {
           ...
        }
}

我曾尝试使用此URL:

代码语言:javascript
复制
http://MyServer/Integration/Feed/MyTest 

但是feedKey是空的吗?这跟路由有什么关系吗?

编辑1:

代码语言:javascript
复制
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:

代码语言:javascript
复制
routes.MapRoute(
                "IntegrationFeed", // Route name
                "{controller}/{action}/{name}/{feedKey}", // URL with parameters
                new { controller = "Integration", action = "Feed", name = string.Empty, feedKey = "" }
            );
EN

回答 1

Stack Overflow用户

发布于 2012-11-27 02:15:39

您是否为feedKey定义了路由?使用默认路由时,应该可以执行以下操作(将feedKey更改为id)。

代码语言:javascript
复制
    [AcceptVerbs(HttpVerbs.Get)]
    public ContentResult Feed(string id)
    {
       // ...
    }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13570672

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档