3

In an ASP.NET MVC 4 application, I would like to get the URL of the site calling the application. That is, I would like to be able to change the web site slightly depending upon which URL it is called from, and as such need to know how to tell what the calling URL is? I would then call a different index.cshtml file depending on which site it is called from.

Any help would be appreciated

1 Answer 1

5

I'm not completely sure what you want to do, but would this do the trick for you:

Request.UrlReferrer

Or

Request.ServerVariables["HTTP_Referer"]

Although I'd prefer the first one.

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

1 Comment

Thanks Robert. I am a newbie developer. Am I right in assuming I would be able to test in developer mode, it will just show a localhost address? Secondly, a "var test = Request.UrlReferer", does not get me an outcome, how would I get in a variable. Appreciate your help, so about the low level questions?

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.