1

in my web application Request.UrlReferrer is null. how can i set UrlReferrer ?

2
  • 1
    possible duplicate of Request.UrlReferrer null!? Commented Feb 15, 2011 at 9:47
  • what do you need it for? IMO you better look for alternative way as the referrer is not stable to begin with. Commented Feb 15, 2011 at 9:57

2 Answers 2

2

You don't need to set the UrlReferrer. The referrrer is something that the browser sends to the server. This property is how you read what the browser sent as a referrer. For obvious reasons you cannot set what the browser sends you because your server does not control it.

Why do you want to set it anyway?

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

2 Comments

actualy i don't want to set UrlReferrer, I want to be sure that UrlReferrer is not null. But in my application(when i logged in) is null.
You cannot depend on UrlReferrer because the browser may not send it. What is more someone can open the page directly.
0

you want to make sure UrlReferrer is not null. if you do not it can create 'Object reference not set to an instance of an object.' error.

if (!(Request.UrlReferrer == null)) {
    'if Request.UrlReferrer is not null do this 
}
else {
    'set Request.UrlReferrer to null
}

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.