user3953989
user3953989

Reputation: 1929

How to create relative url usable between different deployments

I have a simple aspnet core web app that I run locally at my root http://localhost/ and I'm publishing it to my IIS server which is http://192.168.1.100/MyApp when I click on any links, I'm always brought to the root of the domain and not my sub-app.

I've tried relative urls like href='/home/index', href='home/index' but they work in one place and not another.

Is there a way to accomplish this with either vanilla html or some razor?

Upvotes: 0

Views: 37

Answers (1)

Michael Snyder
Michael Snyder

Reputation: 21

Toss a tilde (~) in front of any links you're creating with Razor, which will make the link relative to the app's root.

Upvotes: 1

Related Questions