1

I am using $http.get with a relative url like this:

 $http.get('/api/product')
                .then(function (res) { });

The resultant call is:

GET http://localhost/api/product 404 (Not Found) 

Now the problem is my site is running in IIS under a virtual directory, the structure is like this:

Sites
    - Default Web Site
        - Website (Virtual Directory)
        - Services (Virtual Directory)

So the URL I actually want AngularJs to call is:

GET http://localhost/website/api/product

I have tried setting the BASE element like this:

<base href="Website/">

(And using http://localhost/website/)

But nothing seems to correct the URL?

What can I do? I would still like to use the relative URL with angularjs.

2 Answers 2

1

Try this: $http.get('api/product') .then(function (res) { });

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

Comments

1

Change from

$http.get('/api/product').then(function (res) { });
to
$http.get('/website/api/product').then(function (res) { });

3 Comments

Can you provide more explanation?
Change from $http.get('/api/product').then(function (res) { }); to $http.get('/website/api/product').then(function (res) { });
To score points, it helps if you update the answer with that comment :)

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.