KenyaPlex.com
    Colleges   Schools   Universities   Alumni Directory   Courses   Interview Questions   Forum   Question Papers   Members   Online Tests   Tutorials  
Sign In    RegisterBusiness DirectoryJobs Submit Resume Ask a QuestionChat Room Upload Photo Advertise Here Web Design Who is new?


Alumni Directory
Join our alumni directory today and find your current or former classmates from school, college or university.
Join Now!

Search for schools
Get information on all schools in Kenya. Choose from the best.

Colleges
Find all colleges in Kenya from our easy to use colleges directory.

Universities
Find both public and private universities.

Discussion Forum
Discuss and share ideas. Ask questions and get answers

Interview Questions
Browse our collection of interview questions and resources and prepare yourself to win interviews.

Kasneb CPA Syllabus

Registered Members
Lilian Mosiori Morishwa
muga diana akinyi
PETER H GATHUNGU
Fred Awili
caroline wanjiru

More Members | Register

 
Skip Navigation LinksHome > >Discussion Forum > >Blocking a particular IP from accessing your website in asp.net
 

Blocking a particular IP from accessing your website in asp.net


Last Updated: 06/23/2010 02:14:54
Total Responses: 1
Posted By: samuel
There are times when you need to block a specific IP address from accessing your website.
In asp.net, you have to do it by writing a code in Global.asax Application_AuthenticateRequest.
It can easily be done through the code snippet shown below.
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
string ip = HttpContext.Current.Request.UserHostAddress.ToString();
if (ip == ConfigurationSettings.AppSettings["Blocked"].ToString())
Response.StatusCode = 403;
}
Make sure that in the web.config file you add a key called "Blocked" and give its value as the IP you want to block.
Happy programming!

Responses

marto  says..
Can the same method be used to block a series or group of IPs from accessing a site?

28 Sep 2009 @ 11:41

Post Reply/Response


You must Sign In  to post a response.

More Resources


Strathmore University Introducing Bachelor of Business Science Programme
College Directory in Kenya
INTAKE QUERY
Dealing with questions about age and experience in an interview
Moi University School of Engineering Courses
ROLE OF BIOMEDICAL SCIENTIST IN CONTROLING THE UPSURGE OF TRADITIONAL DRUGS
How are CVs evaluated in an organization?
Useful Educational Portal
Scoring highly on aptitude tests
Bachelor of Science in Information Technology at KCA
 



About Us | Contact Us | Privacy Policy | Advertise

Copyright © 2008 KenyaPlex.com: A website for Education in Kenya, Resources, Jobs and Interview Questions - All rights reserved.