1

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.

enter image description here

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?

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

1

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"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.