Click here to Skip to main content
15,888,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I place [HttpPost] filter on Index action of my controller. I get error The resource cannot be found.
Please any body explain me why is this happen.

SQL
public class BooksController : Controller
   {
       public ActionResult Index()
       {
           return View();
       }

above code run easily when i write localhost:1530/Book in browser.
But when I write [HttpPost] on it (as below code) it shows error.

SQL
public class BooksController : Controller
    {
        [HttpPost]
        public ActionResult Index()
        {
            return View();
        }


my routeconfig code is below
C#
public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

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



Explain me why is this happen.
Posted
Updated 23-Aug-13 21:04pm
v2

1 solution

Hi
It looks for me that you are passing null value for the id parameter.

Check this out and if you need further assistance, post me the routing config file contents and the action filter code segments
 
Share this answer
 
Comments
N_cooL 24-Aug-13 3:06am    
Hello sir,
I update my question with routeconfig. I think now you understand my problem and help me out.
Bala Selvanayagam 24-Aug-13 16:52pm    
Could you post me the view side coding as well (there should be a form attribute where you capture the data and post to the controller)?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900