Asp.net MVC 中一对多关系的路由
我有两个控制器
1)ServerController
2)ClientController
这两个控制器都有操作
ServerList,ClientList
AddServer,AddClient
DeleteServer,DeleteClient
,我想遵循休息原则,所以网址应该像这样
http://mydomain/Server/ServerList 将显示所有服务器列表
现在对于特定的 serverid 可能有很多客户端,因此 url 应该是 http://mydomain/Server/serverid(say:1)/Client/ClientList 将显示 serverid 1 的所有客户端列表
http://mydomain/Server/Add 将添加服务器
对于客户来说也是如此......
http://mydomain//Server/id/Delete 这将删除 id 的服务器,
同样删除客户端.. ...
请告诉我应该如何为此编写路线, 提前致谢...
I am having two Controllers
1)ServerController
2)ClientController
Both of These are having actions
ServerList,ClientList
AddServer,AddClient
DeleteServer,DeleteClient
and I want to follow rest principle so urls should be like this
http://mydomain/Server/ServerList which will display all server list
Now for Specific serverid there can be so many clients so url should be
http://mydomain/Server/serverid(say:1)/Client/ClientList which will display all client list for serverid 1
http://mydomain/Server/Add which will add a Server
Same for Client....
http://mydomain//Server/id/Delete which will delete server for id
Same delete for client.....
Please tell me How should I Write Routes for This,
Thanks in Advance...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实现这种情况后,我真的发现了这些东西
1)根据休息原则这些网址将像这样
server/addserver,server/serverid/addclient
//添加服务器和添加客户端(为该服务器添加特定客户端)
server/serverlist,server/serverid/clientlist
//显示服务器列表和客户端列表(针对特定服务器ID显示所有客户端列表)
server/serverid/deleteserver,server/serverid/client
//删除服务器和客户端(对于特定的服务器ID删除所有客户端)
,我很高兴地说,一切都在单一路由下,
这就是我正在寻找的解决方案。
谢谢
After implementing this situation I really found these things
1)According to rest principle these urls will be like this
server/addserver,server/serverid/addclient
//to add server and addclient(to add specific client for that server)
server/serverlist,server/serverid/clientlist
//displaying serverlist and clientlist(for a specific serverid display all clientlist)
server/serverid/deleteserver,server/serverid/client
//deletes server and client(for a specific serverid delete all clients)
and i'm glad to say guys that everthing was under a single route
That was the solution I was looking for.
Thanks