Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Routing for .json and .xml
- Details(id)
- {
- $data = $this->MyController->findById(id);
- if($this->requestType == "json")
- {
- respondAs("json");
- }
- else if($this->requestType == "xml")
- {
- respondAs("xml");
- }
- else
- {
- //does default - html view
- }
- $this->setViewVariable("data", $data);
- }
- routes.MapRoute(
- "Default",
- "{controller}/{action}/{id}/{type}",
- new { controller = "Home", action = "Index", id = UrlParameter.Optional, type = UrlParameter.Optional });
- public ActionResult Index(int id, string type)
- {
- if(type == "json")
- return View("JsonView");
- //etc
- }
Add Comment
Please, Sign In to add comment