What am i doing wrong with this in asp.net-mvc?

Posted by Pandiya Chendur on Stack Overflow See other posts from Stack Overflow or by Pandiya Chendur
Published on 2010-04-26T04:26:09Z Indexed on 2010/04/26 4:33 UTC
Read the original article Hit count: 211

Filed under:
|
|
|

I gave this in my site.master

<li><%= Html.ActionLink("Material", "Index", "Material")%></li>

But my link doesnt seem to get my material controller Index method... I have this in my global asax file,

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default",                                              
                "{controller}/{action}/{id}",                           
                new { controller = "Home", action = "Index", id = "" }  
             );

            routes.MapRoute(
                "Default",                                              
                "{controller}/{action}/{id}",                            
                new { controller = "Material", action = "Index", id = "" }  
            );

        }

My controller:

public class MaterialController : Controller
{
    //
    // GET: /Material/
    Material material = new Material();
    public ActionResult Index()
    {
        var materials = material.FindAllMaterials();
        return View();
    }
 }

What am i doing wrong.... When i click the link i get The resource cannot be found. error.. Any suggestion...

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about link