How to get the WebAPI HelpPage help package for working with the HotTowel template?

I'm testing John Papa's new Hot Towel template. This is really a stain, but I have some difficulty in having it work with what I'm used to for the web API.

I managed to get around the routing problem, but I still can't get the Microsoft.AspNet.WebApi.HelpPage package to work.

Here is what I did:

  • Install Hot Towel VSIX .
  • New ASP.NET MVC4 Projct - Hot Towel SPA Template
  • Build, Run - Works.
  • Right-click the Controllers folder, add a controller named TestController .
  • Select the "Empty API Controller" template.
  • Write the following action in TestController:

     public IEnumerable<string> GetTestData() { return new[] { "A", "B", "C" }; } 
  • Assembly, launch.

  • Try URL /api/test Get 404 error The resource cannot be found.
  • Try url /api/test/gettestdata . Work.

Then I noticed that BreezeWebApiConfig.cs changed the default api route, and {action} is required, so I added the default api route:

 GlobalConfiguration.Configuration.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); 

Now when I try the URL /api/test , it works.

Now I would like to use the help package.

  • Add Microsoft.AspNet.WebApi.HelpPage package nuget.
  • Add AreaRegistration.RegisterAllAreas(); at Global.asax.cs
  • Assembly, launch.

When I try the URL /Help , I get the following error:

 System.InvalidOperationException: The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/Help/Index.aspx ~/Views/Help/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx ~/Views/Help/Index.cshtml ~/Views/Help/Index.vbhtml ~/Views/Shared/Index.cshtml ~/Views/Shared/Index.vbhtml 

What is the correct way to resolve this error without breaking the HotTowel pattern?

Should any of these be considered errors?

+4
source share
3 answers

After installing the HotTowel template and creating the application, and then installing HelpPage, I registered the help area as shown below:

 protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); } 

But having done this above, the routes were routed in the following order and noticed similar problems that you talked about.

 a.Breeze Api route b.HotTowel route c.Help page route d.ignored routes e.RouteConfig routes 

So, I fixed the above route order by doing the following:

  • Comment on the call to "[build: WebActivator.PreApplicationStartMethod" in the configuration files in the App_Start folder.

  • Register your routes in the following order at Global.asax.cs. This seems to fix the problem for me when I see the help page, api routes are called, and also browses the home page accordingly.

     protected void Application_Start() { //help page AreaRegistration.RegisterAllAreas(); //api BreezeWebApiConfig.RegisterBreezePreStart(); //hot towel HotTowelRouteConfig.RegisterHotTowelPreStart(); //register bundles HotTowelConfig.PreStart(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); } 
+9
source

Interesting. If you remove the \ comment from the entire HotTowelMvc route definition (in HotTowelRouteConfig.cs) and then replace the default Home string in RouteConfig.cs with HotTowel, everything works fine, including the help package.

+3
source

Have you added your own route? Breeze routes will not work for any custom you add.

0
source

All Articles