Click here to Skip to main content
16,017,333 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to get URL of requesting web site in My WEB API 2. I need to do this because of security. I want to response to the request which are coming from the URLs that are registered on my server.

In Web API I have used

1) Owin
2) OAuth 2.0

So far I have tried to get it from owin context and http context but no one gives URL. I am able to get IP address of the requesting web site.

Any idea how can I achieve this?

What I have tried:

So far I have tried to get it from owin context and http context but no one gives URL. I am able to get IP address of the requesting web site.

Any idea how can I achieve this?
Posted
Updated 6-Oct-19 23:44pm
Comments
Nathan Minier 3-Aug-16 7:30am    
Yeah, you're trying to mine DNS data out of an HTTP packet, that's not going to work.

You're going to need to make a DNS request for each packet (unless you have sessions implemented, but that would sort of defeat the purpose of WebAPI).

I guess you could add a database table that maps IPs to URLs and update it periodically. Whatever floats your boat.

Have a look at Dns.GetHostEntry():
https://msdn.microsoft.com/en-us/library/system.net.dns(v=vs.110).aspx

1 solution

you can get the website url from request Headers:
context.Request.Headers["origin"];
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900