[英]How to create meaningful route in ASP MVC 3 with Entity Framework for related Entities?
Let's say I have two entities: 假设我有两个实体:
Company 1 -> * User 公司1-> *用户
If I want to go to the company 1, I use 如果我想去公司1,我用
http://localhost/Company/Details/1 http:// localhost / Company / Details / 1
What if I want to access the company Users? 如果我想访问公司用户该怎么办?
http://localhost/Company/Details/1/Users http:// localhost / Company / Details / 1 /用户
What if I want a pre-filled for adding users to this company? 如果我要预先填写将用户添加到该公司该怎么办?
http://localhost/Company/Details/1/Create http:// localhost / Company / Details / 1 /创建
How can I configure those routes and rewrite them to use the User controller, with the company parameter set? 如何设置公司参数,配置这些路由并重写以使用User控制器?
This is my best guess: 这是我最好的猜测:
routes.MapRoute(
"CompanyUsers",
"Company/Details/{company_id}/{action}",
new { controller = "User", id = company_id }
);
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.