Reputation: 9063
I want to publish my project to a folder in IIS but with the routes setup the way it is I get what looks like an internal loop and not finding the path.
I published the project in a folder already
angular.module("common.services", ["ngResource"])
.constant("appSettings",
{
//serverPath: "http://localhost:53967/"
//name of the computer and folder to which the project was published
serverPath:"http://ct-dx-ariang/AspNetWebApi/"
});
And have a resource setup as follow
angular.module("common.services").factory("productResource", ["$resource", "appSettings", productResource])
function productResource($resource, appSettings) {
//return $resource(appSettings.serverPath + "/api/products/:search");
return $resource(appSettings.serverPath + "/api/products/:id"
These are my routes
$urlRouterProvider.otherwise("/");//default url
$stateProvider.state("home", {
url: "/",
templateUrl: "/templates/welcomeView.html"
}).state("productList", {
url: "/products",
templateUrl: "/templates/productListView.html",
controller: "ProductListController"
}).
How can I modify this sample project so that it runs in the published folder on the IIS as opposed to in localhost on visual studio?
Upvotes: 1
Views: 137
Reputation: 18295
A slash at the beginning of a path makes that path relative to the root of the site. So in your case:
templateUrl: "/templates/productListView.html"
will always refer to http://myhostname/templates/productListView.html
, no matter in which subpath is hosted your site.
Removing the first slash may solve your issue:
templateUrl: "templates/productListView.html"
Also looking at your $resource
configuration:
return $resource(appSettings.serverPath + "/api/products/:id"
And your AppSettings
constant:
serverPath:"http://ct-dx-ariang/AspNetWebApi/"
Seems to me that you are adding two consecutive slashes to your $resource
path. The resulting path will be: http://ct-dx-ariang/AspNetWebApi//api/products/:id
Upvotes: 2
Reputation: 1039428
These are my routes
Pretty hardcoded. Make sure that you use the same constant over there for all your templates as well.
templateUrl: appSettings.serverPath + "/templates/welcomeView.html"
Upvotes: 1