How To Block a Specific Site For a Specific Time Using Host File

Today, we are going to discuss how to block a specific site for a specific time, using host file.

For this task, we need to follow only two steps.

  1. Create two console applications (one for disabling and one for enabling).
  2. Need to create one scheduler which will block and unblock the site.

Step 1: The below console application will write the sitetoblock code in host file.
code
Once you've written the code in the file, the site will be blocked. The below mentioned console application will be used for unblocking the site. It will remove that line which was added for blocking the site in host file.

code
Step 2: Need to create two schedulers and attach the console applications to them and need to set time according to our time.

Steps to attach the console application to the scheduler.

console application

console application

console application

console application

console application

console application

Similarly, create scheduler for unblocking the application and running the scheduler.

Thanks for visiting this blog.