Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Figuring out the correct URL
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
MVC
Title:
Figuring out the correct URL
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01620834
Message ID:
01620834
Views:
61
Hi everybody,

I am trying to figure out how to construct my URL (and route) in order to be able to pass different parameters.

I have the following class working correctly when called from the menu:
 [RouteArea("CapacityControl")]
    [RoutePrefix("Max4Sales")]
    [Authentication()] 
    public class Max4SalesController : BaseController
    {
        public Max4SalesController(IHttpContextManager httpContextManager) 
        : base(httpContextManager)
        {
            
        }
              
        [Route("")]
        public ActionResult Index()
        {            
            ViewBag.departmentId = 0;
            ViewBag.categoryId = 0;
            ViewBag.itemId = 0;
            return View();
        }

        [Route("Department/{departmentId}")]
        public ActionResult DepartmentById(int departmentId)
        {
            ViewBag.departmentId = departmentId;
            ViewBag.categoryId = 0;
            ViewBag.itemId = 0;
            return View("Index");
        }
The first route is what works correctly. The URL I see in the browser is "http://localhost:5525/CapacityControl/Max4Sales"

I want to somehow be able to call it and pass either departmentId or categoryId or itemId and let it resolve to correct route and logic.

Unfortunately, all variations I've tried in the url line of the browser either resulted in the main route being called (the first one) or in 404 error.

How should I correctly call and create routes for the cases I want?

Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform