0

window.location.origin works fine but my application is hosted in different directory, I mean, root url of production is xyz.com/InnerDirectory. On local host window.location.origin works but on production it gives xyz.com but I need xyz.com/InnerDirectory How can I achieve this?

Imad
  • 7,126
  • 12
  • 55
  • 112

1 Answers1

1

Javascript can't know what's the the root path of your application.
But since you tagged your question with asp.net, you can use virtual paths and asp.net will handle the paths for you.

So instead of:

<sometag src="xyz.com/InnerDirectory/something.css">

Write this:

<sometag src="~/something.css">

Read more here.

BTW, if you use ASP.NET MVC, it's even easier as you should use the @Url.Content \ Url.Action helpers

gdoron
  • 147,333
  • 58
  • 291
  • 367