在web.config中加入
<system.web>
<authentication mode="Forms">
<forms name="myCookie" loginUrl="login.aspx">
</forms>
</
authentication>
<authentication>
<deny users="?"/>
</authentication>
</
authentication>
</system.web>