Guest User

Untitled

a guest
Feb 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. public ActionResult Index(string version = null)
  2. {
  3. if (!string.IsNullOrWhiteSpace(version))
  4. {
  5. if (version == "V1")
  6. return View("Index", new HomeViewModel
  7. {
  8. Version = settingsProvider.CurrentApiVersion
  9. });
  10. if (version == "V2")
  11. return View("AngularApp");
  12. }
  13. return View("AngularApp");
  14. }
  15.  
  16. ublic class RouteConfig
  17. {
  18. public static void RegisterRoutes(RouteCollection routes)
  19. {
  20. routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  21.  
  22. //enable attribute routing
  23. routes.MapMvcAttributeRoutes();
  24.  
  25. routes.MapRoute(
  26. name: "Default",
  27. url: "{controller}/{action}/{id}",
  28. defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
  29. constraints: new
  30. {
  31. serverRoute = new ServerRouteConstraint(url =>
  32. {
  33. return !url.PathAndQuery.StartsWith("/App-", StringComparison.InvariantCultureIgnoreCase);
  34. })
  35. }
  36. );
  37.  
  38. routes.MapRoute(
  39. name: "angular",
  40. url: "{*url}",
  41. defaults: new {controller = "Home", action = "Index"});
  42. }
  43. }
  44.  
  45. const routes: Routes = [
  46. {path: '', redirectTo: 'App-Documentation', pathMatch: 'full'}
  47. ,
  48. {
  49. path: '',
  50. component: LayoutComponent,
  51. children: [
  52. {
  53. path: '',
  54. component: DocumentationComponent
  55. },
  56. {
  57. path: 'App-Documentation',
  58. component: DocumentationComponent
  59. },
  60. {
  61. path: 'App-Settings',
  62. component: AdministrationComponent
  63. },
  64. {
  65. path: 'App-Chat',
  66. component: ChatComponent
  67. }
  68. ]
  69. },
  70. { path: '**', redirectTo: 'App-Documentation' }
  71. ];
  72.  
  73. [RoutePrefix("")]
  74. public class ClientApiController : ApiBaseController
  75. {
  76.  
  77. serverRoute = new ServerRouteConstraint(url =>
  78. {
  79. return !url.PathAndQuery.StartsWith("/App-", StringComparison.InvariantCultureIgnoreCase);
  80. })
  81.  
  82. routes.MapRoute(
  83. name: "angular",
  84. url: "{*url}",
  85. defaults: new {controller = "Home", action = "Index"});
  86.  
  87. { path: '**', redirectTo: 'App-Documentation' }
Add Comment
Please, Sign In to add comment