How does the ASP.NET Web API project template use this HelpPage area like it weren't an area?












0















Open a new ASP.NET Web API project in Visual Studio 2017 Community (or whichever edition) and run it and you'll see a welcome page with an API hyperlink.



Click the hyperlink and it takes you to the url http://localhost:<port>/Help.



That's the Index action on the HelpController in the HelpPage area.



However, what I am confused by is the following:




  1. There is no area registration for the HelpPage area.


  2. This ActionLink call is outright wrong. It says, "Please call the Index action on the HelpController within the default area-less area."



From _Layout.cshtml in the project root



<li>@Html.ActionLink("API", "Index", "Help", new { area = "" }, null)</li>

That's outright abusive. How does that work?



  1. Wait, shouldn't the default route for this action be localhost:<port>/HelpPage/Help/[optional:Index]? Where's the route configuration for this area? If it is absent, the routing should go by the only default route declared in the root, area-less area, right?










share|improve this question



























    0















    Open a new ASP.NET Web API project in Visual Studio 2017 Community (or whichever edition) and run it and you'll see a welcome page with an API hyperlink.



    Click the hyperlink and it takes you to the url http://localhost:<port>/Help.



    That's the Index action on the HelpController in the HelpPage area.



    However, what I am confused by is the following:




    1. There is no area registration for the HelpPage area.


    2. This ActionLink call is outright wrong. It says, "Please call the Index action on the HelpController within the default area-less area."



    From _Layout.cshtml in the project root



    <li>@Html.ActionLink("API", "Index", "Help", new { area = "" }, null)</li>

    That's outright abusive. How does that work?



    1. Wait, shouldn't the default route for this action be localhost:<port>/HelpPage/Help/[optional:Index]? Where's the route configuration for this area? If it is absent, the routing should go by the only default route declared in the root, area-less area, right?










    share|improve this question

























      0












      0








      0








      Open a new ASP.NET Web API project in Visual Studio 2017 Community (or whichever edition) and run it and you'll see a welcome page with an API hyperlink.



      Click the hyperlink and it takes you to the url http://localhost:<port>/Help.



      That's the Index action on the HelpController in the HelpPage area.



      However, what I am confused by is the following:




      1. There is no area registration for the HelpPage area.


      2. This ActionLink call is outright wrong. It says, "Please call the Index action on the HelpController within the default area-less area."



      From _Layout.cshtml in the project root



      <li>@Html.ActionLink("API", "Index", "Help", new { area = "" }, null)</li>

      That's outright abusive. How does that work?



      1. Wait, shouldn't the default route for this action be localhost:<port>/HelpPage/Help/[optional:Index]? Where's the route configuration for this area? If it is absent, the routing should go by the only default route declared in the root, area-less area, right?










      share|improve this question














      Open a new ASP.NET Web API project in Visual Studio 2017 Community (or whichever edition) and run it and you'll see a welcome page with an API hyperlink.



      Click the hyperlink and it takes you to the url http://localhost:<port>/Help.



      That's the Index action on the HelpController in the HelpPage area.



      However, what I am confused by is the following:




      1. There is no area registration for the HelpPage area.


      2. This ActionLink call is outright wrong. It says, "Please call the Index action on the HelpController within the default area-less area."



      From _Layout.cshtml in the project root



      <li>@Html.ActionLink("API", "Index", "Help", new { area = "" }, null)</li>

      That's outright abusive. How does that work?



      1. Wait, shouldn't the default route for this action be localhost:<port>/HelpPage/Help/[optional:Index]? Where's the route configuration for this area? If it is absent, the routing should go by the only default route declared in the root, area-less area, right?







      asp.net-mvc asp.net-web-api asp.net-mvc-areas






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 28 '18 at 11:07









      Water Cooler v2Water Cooler v2

      12.8k29104208




      12.8k29104208
























          1 Answer
          1






          active

          oldest

          votes


















          1














          There is an AreasHelpPageHelpPageAreaRegistration.cs file taking care of the area registrations, shown below.
          (I'am using Visual Studio 2017 Enterprise edition.)



          Notice that the HelpPageAreaRegistration class registers the route Help/{action}/{apiId} that uses a constant url-template part Help which doesn't match with the name of the area HelpPage.

          (By convention, this route would have been HelpPage/{controller}/{action}/{id}.)



          Doing so, you don't have to (and must not) specify the area name in the @html.ActionLink, as this controller has an 'explicit' route, which avoids conflicts with other routes, including those from the default area.

          This route must be configured from within the AreaRegistration and not in RouteConfig in order for the views to be resolved from the appropriate views folder within this HelpPage area.



          public class HelpPageAreaRegistration : AreaRegistration
          {
          public override string AreaName
          {
          get{ return "HelpPage"; }
          }

          public override void RegisterArea(AreaRegistrationContext context)
          {
          context.MapRoute(
          "HelpPage_Default",
          "Help/{action}/{apiId}",
          new { controller = "Help", action = "Index", apiId = UrlParameter.Optional });

          HelpPageConfig.Register(GlobalConfiguration.Configuration);
          }
          }





          share|improve this answer


























          • Damn! How did I miss seeing that.

            – Water Cooler v2
            Nov 29 '18 at 13:55











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53518017%2fhow-does-the-asp-net-web-api-project-template-use-this-helppage-area-like-it-wer%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          There is an AreasHelpPageHelpPageAreaRegistration.cs file taking care of the area registrations, shown below.
          (I'am using Visual Studio 2017 Enterprise edition.)



          Notice that the HelpPageAreaRegistration class registers the route Help/{action}/{apiId} that uses a constant url-template part Help which doesn't match with the name of the area HelpPage.

          (By convention, this route would have been HelpPage/{controller}/{action}/{id}.)



          Doing so, you don't have to (and must not) specify the area name in the @html.ActionLink, as this controller has an 'explicit' route, which avoids conflicts with other routes, including those from the default area.

          This route must be configured from within the AreaRegistration and not in RouteConfig in order for the views to be resolved from the appropriate views folder within this HelpPage area.



          public class HelpPageAreaRegistration : AreaRegistration
          {
          public override string AreaName
          {
          get{ return "HelpPage"; }
          }

          public override void RegisterArea(AreaRegistrationContext context)
          {
          context.MapRoute(
          "HelpPage_Default",
          "Help/{action}/{apiId}",
          new { controller = "Help", action = "Index", apiId = UrlParameter.Optional });

          HelpPageConfig.Register(GlobalConfiguration.Configuration);
          }
          }





          share|improve this answer


























          • Damn! How did I miss seeing that.

            – Water Cooler v2
            Nov 29 '18 at 13:55
















          1














          There is an AreasHelpPageHelpPageAreaRegistration.cs file taking care of the area registrations, shown below.
          (I'am using Visual Studio 2017 Enterprise edition.)



          Notice that the HelpPageAreaRegistration class registers the route Help/{action}/{apiId} that uses a constant url-template part Help which doesn't match with the name of the area HelpPage.

          (By convention, this route would have been HelpPage/{controller}/{action}/{id}.)



          Doing so, you don't have to (and must not) specify the area name in the @html.ActionLink, as this controller has an 'explicit' route, which avoids conflicts with other routes, including those from the default area.

          This route must be configured from within the AreaRegistration and not in RouteConfig in order for the views to be resolved from the appropriate views folder within this HelpPage area.



          public class HelpPageAreaRegistration : AreaRegistration
          {
          public override string AreaName
          {
          get{ return "HelpPage"; }
          }

          public override void RegisterArea(AreaRegistrationContext context)
          {
          context.MapRoute(
          "HelpPage_Default",
          "Help/{action}/{apiId}",
          new { controller = "Help", action = "Index", apiId = UrlParameter.Optional });

          HelpPageConfig.Register(GlobalConfiguration.Configuration);
          }
          }





          share|improve this answer


























          • Damn! How did I miss seeing that.

            – Water Cooler v2
            Nov 29 '18 at 13:55














          1












          1








          1







          There is an AreasHelpPageHelpPageAreaRegistration.cs file taking care of the area registrations, shown below.
          (I'am using Visual Studio 2017 Enterprise edition.)



          Notice that the HelpPageAreaRegistration class registers the route Help/{action}/{apiId} that uses a constant url-template part Help which doesn't match with the name of the area HelpPage.

          (By convention, this route would have been HelpPage/{controller}/{action}/{id}.)



          Doing so, you don't have to (and must not) specify the area name in the @html.ActionLink, as this controller has an 'explicit' route, which avoids conflicts with other routes, including those from the default area.

          This route must be configured from within the AreaRegistration and not in RouteConfig in order for the views to be resolved from the appropriate views folder within this HelpPage area.



          public class HelpPageAreaRegistration : AreaRegistration
          {
          public override string AreaName
          {
          get{ return "HelpPage"; }
          }

          public override void RegisterArea(AreaRegistrationContext context)
          {
          context.MapRoute(
          "HelpPage_Default",
          "Help/{action}/{apiId}",
          new { controller = "Help", action = "Index", apiId = UrlParameter.Optional });

          HelpPageConfig.Register(GlobalConfiguration.Configuration);
          }
          }





          share|improve this answer















          There is an AreasHelpPageHelpPageAreaRegistration.cs file taking care of the area registrations, shown below.
          (I'am using Visual Studio 2017 Enterprise edition.)



          Notice that the HelpPageAreaRegistration class registers the route Help/{action}/{apiId} that uses a constant url-template part Help which doesn't match with the name of the area HelpPage.

          (By convention, this route would have been HelpPage/{controller}/{action}/{id}.)



          Doing so, you don't have to (and must not) specify the area name in the @html.ActionLink, as this controller has an 'explicit' route, which avoids conflicts with other routes, including those from the default area.

          This route must be configured from within the AreaRegistration and not in RouteConfig in order for the views to be resolved from the appropriate views folder within this HelpPage area.



          public class HelpPageAreaRegistration : AreaRegistration
          {
          public override string AreaName
          {
          get{ return "HelpPage"; }
          }

          public override void RegisterArea(AreaRegistrationContext context)
          {
          context.MapRoute(
          "HelpPage_Default",
          "Help/{action}/{apiId}",
          new { controller = "Help", action = "Index", apiId = UrlParameter.Optional });

          HelpPageConfig.Register(GlobalConfiguration.Configuration);
          }
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 28 '18 at 20:05

























          answered Nov 28 '18 at 19:22









          pfxpfx

          5,460122035




          5,460122035













          • Damn! How did I miss seeing that.

            – Water Cooler v2
            Nov 29 '18 at 13:55



















          • Damn! How did I miss seeing that.

            – Water Cooler v2
            Nov 29 '18 at 13:55

















          Damn! How did I miss seeing that.

          – Water Cooler v2
          Nov 29 '18 at 13:55





          Damn! How did I miss seeing that.

          – Water Cooler v2
          Nov 29 '18 at 13:55




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53518017%2fhow-does-the-asp-net-web-api-project-template-use-this-helppage-area-like-it-wer%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

          Calculate evaluation metrics using cross_val_predict sklearn

          Insert data from modal to MySQL (multiple modal on website)