AttributeRouting does not work

2019-07-19 21:33发布

I put [AttributeRouting.Web.Mvc.Route("faq.html")] on my action Faq.

However when I go to

localhost/faq.html 

I get a 404 http not found error and I can't find my custom routes in localhost/routes.axd.

How can i fix this ?

thanks !

updated: here is my faq action

    [OutputCache(Duration = 120)]
    [AttributeRouting.Web.Mvc.Route("faq.html")]
    public virtual ActionResult FAQ(int id = 0){
        //some code here 
    }

1条回答
别忘想泡老子
2楼-- · 2019-07-19 21:57

Try code below:

[OutputCache(Duration = 120)]
[AttributeRouting.Web.Mvc.Route("faq.html/{id?}")]
public virtual ActionResult FAQ(int id = 0){
    //some code here 
}

or remove "id" parameter from FAQ method.

Explanation for AttributeRouting

查看更多
登录 后发表回答