0

I'm using Asp.Net MVC. I want to know the url from which a request has been sent to my controller action.For example my controller action is(Customer/Index) and I want to get the url from which, my action is called.(I don't need the current URL).I want the source URL from which the request sent to me. Is there any solution?

2 Answers2

1

You could try using url referrer e.g.

Request.UrlReferrer
Request.QueryString["Referrer"].ToString()
mciesla
  • 72
  • 6
  • Request.UrlReferrer works if the request comes from outside of my website. But I want to know both coming requests from outside an inside my website. – Reza Makvandi Jul 06 '19 at 11:55
0

Have a look at this link: MDN reference

It states that "A Referer header is not sent by browsers if: The referring resource is a local "file" or "data" URI."

If you want to have that available if your page calls 'itself' i.e. another page/controller in you web application, you can try to add the header manually on a per request basis.

mnemonic
  • 692
  • 1
  • 9
  • 18