开发者

Find Out if ASP.NET Request Came From Local Machine

开发者 https://www.devze.com 2023-01-08 00:34 出处:网络
I\'ve built an ASP.NET application that\'s using Forms Authentication. In our hosting account control panel, I set up an automated task that requests a web page once per week. When the page loads, a n

I've built an ASP.NET application that's using Forms Authentication. In our hosting account control panel, I set up an automated task that requests a web page once per week. When the page loads, a number of emails are sent out.

I'd just like to know if there's any way to determine in the code-behind if the request is coming from the local machine (as with Windows authentication). Using a separate web.config file in the page sub-directory with Windows authentication mode doesn't work.

The application will work fine either way. I'm requiring that a specific Guid value be present in the query string, so it's very unlikely that the task will be executed by mistake. I'd just like to learn something new while I'm working on thi开发者_JS百科s, and I'd like to see if I can add this little bit of extra verification.

Thanks very much for any advice.


Request.IsLocal

The IsLocal property returns true if the IP address of the request originator is 127.0.0.1 or if the IP address of the request is the same as the server's IP address.


Request.Url.IsLoopback
0

精彩评论

暂无评论...
验证码 换一张
取 消