21 asp.net-routing asp.net-mvc-3
我正在编写一个MVC控制器,我需要同时处理数据返回以及长期轮询"数据已经改变",就像来自SAME(!)url的行为一样.我无法做到这一点 - 我正在为现有的应用程序实现代理,所以我无法对API进行任何扩展/修改.
我的主要问题是:*POST操作必须立即完成.*GET操作需要更长时间(有时可能需要数小时).
我可以以某种方式重写两个去不同的控制器?另一种选择是......嗯......同时做两个异步,只有POST完成三个然后.
有人对此发表评论吗?
mry*_*ren 45
您应该能够在路由级别使用约束来控制URL进入哪个控制器/操作.
routes.MapRoute(
"route that matches only GETs for your url",
"your url",
new { controller = "some controller", action = "some action" },
new { httpMethod = new HttpMethodConstraint("GET") }
);
routes.MapRoute(
"route that matches only POSTs for your url",
"your url",
new { controller = "some other controller", action = "some other action" },
new { httpMethod = new HttpMethodConstraint("POST") }
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7763 次 |
| 最近记录: |