Click here to Skip to main content
13,195,170 members (67,651 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi guys,
I want to use route attribute in area but i could not.

it's RouteConfig.cs

 public class RouteConfig
        public static void RegisterRoutes(RouteCollection routes)
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }, namespaces: new[] {"OgrenciEvi.Controllers"}


    public class UniversityController : Controller
        SiteContext db = new SiteContext();
        // GET: Manager/University
        public ActionResult BuildingAdd(int UniID)
            ViewBag.UniList = new SelectList(db.University, "UniID", "UniName");
            return View();
        public ActionResult BuildingAdd(BuildingModel NewBuilding)
            if (Request.Form["btnSave"] != null)
                if (ModelState.IsValid)
            return RedirectToAction("BuildingAdd", "University", new { uniid = NewBuilding.UniID});

BuildingApp page's url should be "/Manager/University/BuildingAdd/5" or "/Manager/University/BuildingAdd"

but I got "Source could not find" error.

What I have tried:

Posted 14-Feb-17 3:54am
Updated 14-Feb-17 9:26am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Your RouteArea is overriding the default route config (the controller name) when you move from convention to attributed routing.

Try "/Manager/BuildingAdd/5"
Karthik Bangalore 14-Feb-17 22:58pm

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171019.1 | Last Updated 14 Feb 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100