Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Figuring out the correct URL
Message
 
 
À
10/06/2015 12:17:36
Information générale
Forum:
ASP.NET
Catégorie:
MVC
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01620834
Message ID:
01620841
Vues:
32
>>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.
>
>Based on your route attribute, for the departmentId option you would want to call http://localhost:5525/CapacityControl/Max4Sales/Department/{departmentId}

I thought I've tried this before, but I just re-tried and my controller MVC method was called. The form still displayed wrongly, but I can figure out from here, I hope.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform