//代码
<%
if Session("user")="" then
Response.Write"<script language=javascript>alert(""你还没有登陆!或登陆超时!"");</script>"
response.write "<script language=javascript>parent.location.href='../index.asp';</script>"
response.End()
end if
%> asp的 怎么解决 IE和别的 浏览器的兼容!
啥叫不兼容?而且应该这么判断
if Session("user")=Nothing then
...Session默认20分钟过期。
指的是20分钟没有request进来。
Session根本就不存在不兼容这一说
Forms验证
<configuration>
<system.web>
<authentication mode="Forms">
<forms name="MYWEBAPP.ASPXAUTH" loginUrl="login.aspx"
protection="All" path="/"/>
</authentication>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
<location path="admin">
<system.web>
<authorization>
<allow roles="Administrator"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
<location path="users">
<system.web>
<authorization>
<allow roles="User"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
</configuration>
还可使用BasePage判断,所有页面继承BasePage
public class BasePage : System.Web.UI.Page
{
public BasePage()
{
}
protected override void OnInit(EventArgs O)
{
if (base.Session["UserId"] == null || base.Session["UserId"].ToString().Equals(""))
{
Response.Redirect("~/Error.aspx");
}
}
或IhhtpModule FormsAuthentication.SignOut();
Session.Clear();
Session.Abandon();
转自http://topic.csdn.net/u/20091117/12/a291373f-4c07-416f-9986-8b1d7ed857ed.html
function Reconnect() {
var url = 'xj.aspx'
xmlHttp = createXmlHttpRequest()
xmlHttp.open('GET', url, true)
xmlHttp.send(null)
//只要求与服务器联系,不要求返回数据,因此,不进行返回处理
}function refreshme() {
setInterval("Reconnect();", 50000); //此时间根据实际情况调整
}