code_junkie

ASP.NET MVC being too clever with its routing file and I cant see how!

Nov 13th, 2011
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. routes.MapRoute(
  2. "Products AJAX",
  3. "Products/Ajax/{action}",
  4. new { controller = "Products" }
  5. );
  6.  
  7. routes.MapRoute(
  8. "Product",
  9. "Products/{id}",
  10. new { controller = "Products", action = "ViewProduct", id = "1001" }
  11. );
  12.  
  13. public class ProductsController : Controller {
  14. public ContentResult GetStatus()
  15. {
  16. return new ContentResult()
  17. {
  18. Content = "Status is OK at " + DateTime.Now.ToLongTimeString()
  19. };
  20. }
  21. }
  22.  
  23. <%= Ajax.ActionLink("Update Status", "AJAX/GetStatus", new AjaxOptions { UpdateTargetId = "status" })%>
  24.  
  25. MapRoute(
  26. "Products AJAX",
  27. "Products/Foo/{action}",
  28. new { controller = "Products" }
  29. );
  30.  
  31. <%= Ajax.ActionLink("Update Status", "GetStatus", new AjaxOptions { UpdateTargetId = "status" })%>
Add Comment
Please, Sign In to add comment