{"id":1557,"date":"2016-10-17T06:57:12","date_gmt":"2016-10-17T06:57:12","guid":{"rendered":"http:\/\/elbsolutions.com\/projects\/?p=1557"},"modified":"2022-02-03T11:24:32","modified_gmt":"2022-02-03T17:24:32","slug":"angular-servicestack-net-changing-root-path-nightmare","status":"publish","type":"post","link":"https:\/\/elbsolutions.com\/projects\/angular-servicestack-net-changing-root-path-nightmare\/","title":{"rendered":"angular and servicestack in .net &#8211; changing the root path is a nightmare"},"content":{"rendered":"<p>OK &#8211; first, it is because all these great tools are assuming the root url is \/. They all give part of the picture, but they don&#8217;t know the whole story. Neither <del>do<\/del> did I. But do I google root uri, base url, AHHHH! Anyways, lets document this so I don&#8217;t and you don&#8217;t have to go nuts and google for hours like I did.<\/p>\n<p>First &#8211; I am using ServiceStackVS 4.x, and it is an angular (not MVC &#8211; that might be a mistake) app.\u00a0 I want<\/p>\n<ul>\n<li>myweb.com\/myApplication\/myServices for the services and<\/li>\n<li>myweb.com\/myApplication for the application.<\/li>\n<\/ul>\n<h2>So for ServiceStack (I installed the extension ServiceStackVS into Visual Studio 2013) &#8230;<\/h2>\n<ul>\n<li>&#8211; change the web.config line from a &#8220;*&#8221; to &#8220;myApplication\/myServices*&#8221; in the lines that look like:<\/li>\n<\/ul>\n<p><!--more--><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;br data-mce-bogus=&quot;1&quot;&gt;\r\n\r\n&lt;httpHandlers&gt;\r\n&lt;add path=&quot;myApplication\/myServices*&quot; type=&quot;ServiceStack.HttpHandlerFactory, ServiceStack&quot; verb=&quot;*&quot;\/&gt;\r\n&lt;;\/httpHandlers&gt;;\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<ul>\n<li>Then add the HandlerFactoryPath to look like (in AppHost.cs)<\/li>\n<\/ul>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">&lt;\/pre&gt;\r\nSetConfig(new HostConfig\r\n{\r\nDebugMode = AppSettings.Get(&quot;DebugMode&quot;, false),\r\nAddRedirectParamsToQueryString = true,\r\nHandlerFactoryPath = &quot;myApplication\/myServices&quot;\r\n});\r\n&lt;pre&gt;<\/pre>\n<h2>Now for the angular\/web part<\/h2>\n<ul>\n<li>edit all the templateUrl: items to NOT have a \/ at the front. So all the \/partials become partials<\/li>\n<li>in all your controllers.js &#8211; you have to remove the \/ and add the myServices so for example, the default hello example on the web &#8230; $http.get(\/hello\/ becomes $http.get(myServices\/hello\/<\/li>\n<li>default.cshtml now edits\n<ul>\n<li>all the href links and add a &lt;base href=&#8221;\/docSnibbets\/&#8221; \/&gt; in the &lt;head&gt; section quite near the top (after title and before anything useful happens).<\/li>\n<li>all the src attributes to REMOVE the \/\n<ul>\n<li>in the &lt;head&gt;<\/li>\n<li>AND (important) in the &lt;body&gt; sections<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>Is this the final server (eg are you publishing?) add the npm stuff&#8230;<\/h2>\n<ul>\n<li>on the publish server &#8211; do you see a node_modules folder after you publish? Likely not.<\/li>\n<li>SOOOO . install nodejs on the target computer to which you are publishing to<\/li>\n<li>go to the inetpub\/&#8230;..\/myApplication directory and type &#8220;npm install&#8221;\n<ul>\n<li>it looks at the package.json file and does all the magic for you<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>The main project&#8217;s properties<\/h2>\n<ul>\n<li>edit the main project&#8217;s properties\n<ul>\n<li>click on the Web tab in Visual Studio<\/li>\n<li>add \/myApplication to the end of the ProjectUrl so it becomes\u00a0http:\/\/localhost:28032\/<span>myApplication<\/span><\/li>\n<li>copy this to the CHECKED Override application root URL\n<ul>\n<li>http:\/\/localhost:28032\/myApplication<\/li>\n<\/ul>\n<\/li>\n<li>Now &#8230; change the port by adding one ***THIS IS THE IMPORTANT BIT ***\n<ul>\n<li>you can also delete the old iis express site <a href=\"https:\/\/gyorgybalassy.wordpress.com\/2013\/12\/02\/cleaning-up-iis-express-configuration\/\">by using this link<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>AHHH! It finally works (<a href=\"http:\/\/elbsolutions.com\/projects\/integrating-asp-app-users-users-permissions-401\/\">assuming you set the permission properly<\/a> \ud83d\ude42 )<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OK &#8211; first, it is because all these great tools are assuming the root url is \/. They all give part of the picture, but they don&#8217;t know the whole story. Neither do did I. But do I google root uri, base url, AHHHH! Anyways, lets document this so I don&#8217;t and you don&#8217;t have [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1557","post","type-post","status-publish","format-standard","hentry","category-general"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>angular and servicestack in .net - changing the root path is a nightmare - ELB Solutions.com Inc.<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/elbsolutions.com\/projects\/angular-servicestack-net-changing-root-path-nightmare\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"angular and servicestack in .net - changing the root path is a nightmare - ELB Solutions.com Inc.\" \/>\n<meta property=\"og:description\" content=\"OK &#8211; first, it is because all these great tools are assuming the root url is \/. They all give part of the picture, but they don&#8217;t know the whole story. Neither do did I. But do I google root uri, base url, AHHHH! Anyways, lets document this so I don&#8217;t and you don&#8217;t have [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/elbsolutions.com\/projects\/angular-servicestack-net-changing-root-path-nightmare\/\" \/>\n<meta property=\"og:site_name\" content=\"ELB Solutions.com Inc.\" \/>\n<meta property=\"article:published_time\" content=\"2016-10-17T06:57:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-03T17:24:32+00:00\" \/>\n<meta name=\"author\" content=\"Etienne Bley\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Etienne Bley\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/angular-servicestack-net-changing-root-path-nightmare\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/angular-servicestack-net-changing-root-path-nightmare\\\/\"},\"author\":{\"name\":\"Etienne Bley\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"headline\":\"angular and servicestack in .net &#8211; changing the root path is a nightmare\",\"datePublished\":\"2016-10-17T06:57:12+00:00\",\"dateModified\":\"2022-02-03T17:24:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/angular-servicestack-net-changing-root-path-nightmare\\\/\"},\"wordCount\":471,\"articleSection\":[\"General\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/angular-servicestack-net-changing-root-path-nightmare\\\/\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/angular-servicestack-net-changing-root-path-nightmare\\\/\",\"name\":\"angular and servicestack in .net - changing the root path is a nightmare - ELB Solutions.com Inc.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\"},\"datePublished\":\"2016-10-17T06:57:12+00:00\",\"dateModified\":\"2022-02-03T17:24:32+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/angular-servicestack-net-changing-root-path-nightmare\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/angular-servicestack-net-changing-root-path-nightmare\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/angular-servicestack-net-changing-root-path-nightmare\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"angular and servicestack in .net &#8211; changing the root path is a nightmare\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\",\"name\":\"ELB Solutions.com Inc.\",\"description\":\"Bringing all your IT Pieces together\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\",\"name\":\"Etienne Bley\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"caption\":\"Etienne Bley\"},\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/author\\\/etienne-bley\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"angular and servicestack in .net - changing the root path is a nightmare - ELB Solutions.com Inc.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/elbsolutions.com\/projects\/angular-servicestack-net-changing-root-path-nightmare\/","og_locale":"en_US","og_type":"article","og_title":"angular and servicestack in .net - changing the root path is a nightmare - ELB Solutions.com Inc.","og_description":"OK &#8211; first, it is because all these great tools are assuming the root url is \/. They all give part of the picture, but they don&#8217;t know the whole story. Neither do did I. But do I google root uri, base url, AHHHH! Anyways, lets document this so I don&#8217;t and you don&#8217;t have [&hellip;]","og_url":"https:\/\/elbsolutions.com\/projects\/angular-servicestack-net-changing-root-path-nightmare\/","og_site_name":"ELB Solutions.com Inc.","article_published_time":"2016-10-17T06:57:12+00:00","article_modified_time":"2022-02-03T17:24:32+00:00","author":"Etienne Bley","twitter_misc":{"Written by":"Etienne Bley","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/elbsolutions.com\/projects\/angular-servicestack-net-changing-root-path-nightmare\/#article","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/angular-servicestack-net-changing-root-path-nightmare\/"},"author":{"name":"Etienne Bley","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"headline":"angular and servicestack in .net &#8211; changing the root path is a nightmare","datePublished":"2016-10-17T06:57:12+00:00","dateModified":"2022-02-03T17:24:32+00:00","mainEntityOfPage":{"@id":"https:\/\/elbsolutions.com\/projects\/angular-servicestack-net-changing-root-path-nightmare\/"},"wordCount":471,"articleSection":["General"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/elbsolutions.com\/projects\/angular-servicestack-net-changing-root-path-nightmare\/","url":"https:\/\/elbsolutions.com\/projects\/angular-servicestack-net-changing-root-path-nightmare\/","name":"angular and servicestack in .net - changing the root path is a nightmare - ELB Solutions.com Inc.","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/#website"},"datePublished":"2016-10-17T06:57:12+00:00","dateModified":"2022-02-03T17:24:32+00:00","author":{"@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"breadcrumb":{"@id":"https:\/\/elbsolutions.com\/projects\/angular-servicestack-net-changing-root-path-nightmare\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/elbsolutions.com\/projects\/angular-servicestack-net-changing-root-path-nightmare\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/elbsolutions.com\/projects\/angular-servicestack-net-changing-root-path-nightmare\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/elbsolutions.com\/projects\/"},{"@type":"ListItem","position":2,"name":"angular and servicestack in .net &#8211; changing the root path is a nightmare"}]},{"@type":"WebSite","@id":"https:\/\/elbsolutions.com\/projects\/#website","url":"https:\/\/elbsolutions.com\/projects\/","name":"ELB Solutions.com Inc.","description":"Bringing all your IT Pieces together","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/elbsolutions.com\/projects\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39","name":"Etienne Bley","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","caption":"Etienne Bley"},"url":"https:\/\/elbsolutions.com\/projects\/author\/etienne-bley\/"}]}},"_links":{"self":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/1557","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/comments?post=1557"}],"version-history":[{"count":8,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/1557\/revisions"}],"predecessor-version":[{"id":1565,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/1557\/revisions\/1565"}],"wp:attachment":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/media?parent=1557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/categories?post=1557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/tags?post=1557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}