0

I have some pages that are executed by scheduled tasks regularly on the server. How can I make these pages to only be accessible from the server? What I want is that if the page url is used from anywhere other than the server itself it should return an empty page.

By the way, I don't want to compare Request.ServerVariables["REMOTE_ADDR"] with a hard coded IP address

Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171
  • Hey dude, why did you delete your last question on the functions....it was valid and it was going to be reopened.... Guess you did not want a solution. – epascarello Jul 02 '15 at 13:59
  • @epascarello well, I'm trying to solve a problem but everybody was closing downvoting the question. as this fiddle worked: https://jsfiddle.net/u0bprym2/ . I think there is another problem with my code – Ashkan Mobayen Khiabani Jul 02 '15 at 14:05
  • Do something like this instead: https://jsfiddle.net/rhL7b9fq/1/ – epascarello Jul 02 '15 at 14:13
  • @epascarello sorry for answering later, my internet connection seems to have a problem. well I can not do as you said because as I told each function is in a separate page and I just in my master page (that is common for all pages) I try to call all the functions that are valid in the current page – Ashkan Mobayen Khiabani Jul 02 '15 at 14:24
  • @epascarello I found the problem and undeleted the question and added the answer as as a comment. I undeleted the question because I think this is an error that other people would have, so I want to add the answer for others – Ashkan Mobayen Khiabani Jul 02 '15 at 14:43

2 Answers2

1

Edit after the original question was edited:

Create a second web app on a port that's not open.


Original answer:

Looks for the IP from where the request comes. If it is different from the server's IP, reject the call.

Here's how you can get the IP How to get a user's client IP address in ASP.NET?

Community
  • 1
  • 1
Victor Hurdugaci
  • 28,177
  • 5
  • 87
  • 103
1

You can do this with IIS Access Control. There is a link in the following link that goes into more detail.

https://serverfault.com/questions/605398/iis-access-control-by-ip-address-for-specific-files-and-folders

Community
  • 1
  • 1
jmcclure
  • 122
  • 11
  • As I said in the question I don't want to hard code the ip addresses – Ashkan Mobayen Khiabani Jul 02 '15 at 02:00
  • I agree, it is just another option besides what was already posted, but this also wouldn't be related to Request.ServerVariables["REMOTE_ADDR"]. actually little to none programming if at all. – jmcclure Jul 02 '15 at 02:03