If you want to restrict the entire website for specific URL in that case you can configure this at your IIS level as mentioned in the following link.
http://technet.microsoft.com/en-us/library/cc787192(WS.10).aspx[
^]
If you want to restrict some specific pages in that case you can get the url from the “http_referrer’ server variable as follwong
Request.ServerVariables("http_referrer")
Just check the url, if you want to block then redirect the request to some custom access denied page.
Provide more details, if this is not the case.