Question

I'm experimenting with the documentation of http://www.restfulrouting.com/. When I open my routedug the links are like i want. But when I click the link i get a 404. I have the following structure

1. Login
    1.1 Company (Area)
        1.1.1 Departments
        1.1.2 Contacts
        1.1.1 Company info
    1.2 Customer (Area)
        //other information

My folder structure

Controllers (folder)
    customers (folder)
        AreasController.cs
        CompanyController.cs
        TestController.cs
    AccountController.cs

Routes.cs

using System.Web.Routing;
using RestfulRouting;
using extranet.Controllers;
using extranet.Controllers.customers;

[assembly: WebActivator.PreApplicationStartMethod(typeof(extranet.Routes), "Start")]

namespace extranet
{
    public class Routes : RouteSet
    {
        public override void Map(IMapper map)
        {
            map.DebugRoute("routedebug");
            map.Resource<CompanyController>(comp => comp.Only("show"));
            /*******************************
             ********COMPANYAREA*************
             ********************************/
            map.Area<AreasController>("customer", area =>
            {
                area.Resource<TestController>();
                area.Resource<CompanyController>();
            });
        }

        public static void Start()
        {
            var routes = RouteTable.Routes;
            routes.MapRoutes<Routes>();
        }
    }
}

CompanyController

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;
using System.Xml.Serialization;
using System.Web;
using System.Web.Mvc;

namespace extranet.Controllers
{
    public class CompanyController : ApplicationController
    {
        //
        // GET: /Company/

        public ActionResult Index()
        {

            return View();
        }

        public ActionResult Show()
        {
            return View();
        }

    }
}

My question is when I go to {mysite}/customer/company --> I get the 404 page. When i got to {mysite}/company it shows me the page. What am I overseeing or where is my mistake? If I am missing some code here please tell me then I will place an edit.

Thanks in advance

Was it helpful?

Solution

Wow, just spend 4 hours figuring it out. Turns out i dragged the CompanyController from my controllers map to my customers class. Which means the namespace wasn't changed --> means link didn't recognize the controller.

I just had to add: namespace extranet.Controllers.Customers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top