【发布时间】:2014-05-21 09:26:50
【问题描述】:
我正在使用 ASP.Net compact 版本 3.5 S.P.I
我在一个定期调用网络方法的手持扫描仪上运行一个应用程序。
我已在 Web 配置中将表单身份验证超时设置为 60
<authentication mode="Forms">
<forms name="Auth" loginUrl="service1.asmx" protection="All" timeout="60" path="/" slidingExpiration="true" />
</authentication>
<p>
超时倒计时,当应用中的身份验证过期时,用户将重新登录。但是,如果我调用 web Method ,则根本不会重置超时。如果登录超时,用户不会返回登录屏幕。
这是我调用的一种 Web 方法的示例
我不希望为每个 Web 方法添加代码来完成重置超时,但如果我必须这样做的话。
private string SessionID = HttpContext.Current.Session.SessionID;
private string query;
private int UserPK;
private ArrayList myparams = new ArrayList();
private DataSet myTempDataSet = new DataSet();
private int ReturnIntegerTable;
private int ReturnBooleanTable;
[WebMethod(EnableSession = true)]
public DataSet GetBuildUnitDetails(int StockInPK, int UserInPK)
{
try
{
if (Context.User.Identity.IsAuthenticated)
{
myparams.Clear();
myparams.Add(new STASqlParameter("@StockInPK", StockInPK));
myReturnData = STADatabase.SQLStoredProcedureSelect("GetStockInfo", myparams).Tables[0];
myReturnData.TableName = "STA2";
myReturnDataSet.Tables.Add(myReturnData.Copy());
PopulateMyCommonTable(true, SessionID, true, UserInPK);
}
return myReturnDataSet;
}
catch (Exception)
{
PopulateMyCommonTable(false, SessionID, false, UserInPK);
return myReturnDataSet;
}
}
}
</pre>
【问题讨论】:
标签: c# asp.net web-services