dfang
dfang

Reputation: 1386

AttributeRouting does not work

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 
    }

Upvotes: 2

Views: 1642

Answers (1)

Shvarc
Shvarc

Reputation: 161

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

Upvotes: 1

Related Questions