在web.config配置文件中的<system.web>節(jié)點(diǎn)中添加入下節(jié)點(diǎn): <system.web> <authentication mode="Forms"> <forms name="自己取個(gè)名字吧" loginUrl="你的登陸頁(yè)面"></forms> </authentication> </systeml.web> 添加這段后,如果您沒有登陸的話,無論你訪問那個(gè)網(wǎng)頁(yè),都會(huì)跳轉(zhuǎn)到“你上面設(shè)置的頁(yè)面(這里是登陸頁(yè)面)” 在登陸按鈕的單擊事件中添加如下代碼: FormsAuthentication.SetAuthenCookie("用戶名的值",trru(or false)),這里寫true的話將會(huì)保存到cookie中,false 的話不會(huì)保存到cookie中 |
|