1.web.config文件配置:
在Web.config文件 <system.web> <httpHandlers>添加一个节点
<system.web>
<httpHandlers>
<!--禁止访问IPData目录下的文本文件-->
<add path="IPData/*.txt" verb="*" type="System.Web.HttpForbiddenHandler"/>
</httpHandlers>
....
2.根目录新建IPData文件夹,放2个文件canvisit.aspx和important.txt
canvisit.aspx放点代码进去测试:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="canvisit.aspx.cs" Inherits="MyWebSiteTest.IPData.canvisit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="