简体   繁体   English

ASP.NET-具有密码保护页面的Cron作业

[英]ASP.NET - Cron job with password protected page

I am trying to read an xml-feed into a database on a specific time with cron jobs. 我正在尝试使用cron作业在特定时间将xml提要读取到数据库中。 Everything is working fine (the cron job calls the page and the xml-script starts running and reading into the database) except that i dont want someone else to be able to run the script by visiting this page. 一切工作正常(cron作业调用该页面,并且xml脚本开始运行并读取到数据库中),除了我不希望其他人能够通过访问此页面来运行该脚本。 Therefore I have been looking at setting up a password-protected page for this script, but there is not a lot of information about how to do this with cron jobs and asp.net. 因此,我一直在为该脚本设置一个受密码保护的页面,但是关于如何使用cron作业和asp.net进行此操作的信息并不多。

It seems to be so much easier with php (use the htaccess-file and send the username and password with the cron-job url like http://username:password@yoursite.com/cron ). 用php似乎要容易得多(使用htaccess-file并使用cron-job url发送用户名和密码,例如http:// username:password@yoursite.com/cron )。 Is it possible to do this with asp.net sites? 使用asp.net网站可以做到这一点吗?

I have to use cron job since my web hosting provider don't have windows task scheduler. 我必须使用cron作业,因为我的网络托管提供商没有Windows Task Scheduler。

Thanks, Axel 谢谢,阿克塞尔

您可以在特定于目录的web.config中使用通过保护的URL

Two points come to my mind 我想到两点

  1. http://username:password@yoursite.com/cron like url is useless for securing if https is not used. 如果未使用https,则类似url的http:// username:password@yoursite.com/cron不能确保安全。 You can make you asp.net url equivalent to it using query string. 您可以使用查询字符串使asp.net URL等效于它。
  2. If ssl is not possible why dont you enable ip checking that the code will only run when the page is requested from a specific ip(Linux server ip)?? 如果不可能使用ssl,为什么不启用ip检查以确保仅在从特定ip(Linux服务器ip)请求页面时才运行代码?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM