Paritosh
Paritosh

Reputation: 2379

MVC URL routing is not working

This is my Global.asax , all I want to map another url format to controller and action.

        //Matching to auctions-index-Testing
        //Why this one is not matching to auction-index
        routes.MapRoute("TestUrl", "{controller}-{action}-{name}",
            new { name = UrlParameter.Optional }
            );


        //Matching to Home/Index/1
        //Matching to Home/Index
        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );

I am wondering why auction-index is giving me "Resource not found error". Name is optional and it is first entry in table. so it should be matched with the URL

any help and suggestion would be grateful

Upvotes: 0

Views: 106

Answers (1)

Kundan Singh Chouhan
Kundan Singh Chouhan

Reputation: 14282

Try this instead ::

routes.MapRoute("TestUrl", "{controller}-{action}-{name}",
    new { controller = "auctions", 
          action = "index", 
          name = UrlParameter.Optional }
);

Hope this will help !!

Upvotes: 1

Related Questions