碰到问题了.高手们来帮帮我吧..
山里老妖怪 2006-05-29 12:44:48 asp.net做的会员系统已经制作完毕.
近日买了一套OBLOG系统.欲与之进行会员整合
根据官方提提供的整合方法做了一个API.实现了注册同步.但是在做登陆同步的时候碰到了问题
在ASP里面能过SXML2.ServerXMLHTTP.3.0对象提交数据到asp.net会员系统的时候,通过调试证明Cookie和Session已生成,但是我通过刷新asp.net页面试图来取Session和Cookies的时候,却取不到值:
以下是API的代码:
public class UserAPI:IHttpHandler,IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
APIConfig config=new APIConfig();
if(!config.Enable)
{
ApiClass.SendResult(config.AppID,1,"系统并未开启整合接口!");
return;
}
if(context.Request.InputStream.Length>0)
{
XmlDocument xmlDoc=new XmlDocument();
xmlDoc.Load(context.Request.InputStream);
string appid=xmlDoc.SelectSingleNode("//appid").InnerText;
string syskey=xmlDoc.SelectSingleNode("//syskey").InnerText;
string action=xmlDoc.SelectSingleNode("//action").InnerText;
string UserName=xmlDoc.SelectSingleNode("//username").InnerText;
if(ApiClass.ChkSysKey(syskey,UserName))
{
Model.MemberUser mu;
string Message="";
switch(action.ToLower())
{
case "reguser":
mu=GetRequestUser(xmlDoc);
if(BLL.MemberUser.add(mu,out Message))
{
ApiClass.SendResult(config.AppID,0,"");
}
else
{
ApiClass.SendResult(config.AppID,1,Message);
}
break;
case "login":
string password=xmlDoc.SelectSingleNode("//password").InnerText;
string userIp=xmlDoc.SelectSingleNode("//userip").InnerText;
string Cookie=xmlDoc.SelectSingleNode("//savecookie").InnerText;
string UID="";
ArrayList al=new ArrayList();
bool islogin=BLL.MemberUser.Login(UserName,password,out UID,1,out al);
doLogin(islogin,al,CookieDays(Cookie),UID);
break;
case "logout":
break;
case "update":
break;
case "delete":
break;
case "getinfo":
break;
case "checkname":
if(BLL.user.exists(UserName.Trim()))
{
ApiClass.SendResult(config.AppID,1,"该用户已经存在!");
}
else
{
ApiClass.SendResult(config.AppID,0,"");
}
break;
}
}
else
{
ApiClass.SendResult(config.AppID,1,"安全码验证未通过!");
return;
}
}
else
{
ApiClass.SendResult(config.AppID,1,"接收数据出错,请重试!");
return;
}
}
void doLogin(bool islogin,ArrayList al,int Cookie,string UserID)
{
APIConfig config=new APIConfig();
if(islogin==false)
{
string Message="";
for(int i=0;i<al.Count;i++)
{
Message+="<li>"+((Exception)al[i]).Message+"</li>";
}
ApiClass.SendResult(config.AppID,1,Message);
}
else
{
user.UserLogin(UserID,Cookie);
ApiClass.WriteLog("登陆了");
ApiClass.SendResult(config.AppID,0,"");
}
}
int CookieDays(string CaseValue)
{
switch(CaseValue)
{
case "0":
return 0;
case "1":
return 1;
case "2":
return 30;
case "3":
return 365;
default:
return 0;
}
}
Model.MemberUser GetRequestUser(XmlDocument xmlDoc)
{
Model.MemberUser mu=new Model.MemberUser();
mu.PASSWORDFORMAT=4;
mu.USERPASSWORD=Common.DEC.Encrypt(mu.PASSWORDFORMAT,xmlDoc.SelectSingleNode("//password").InnerText);
mu.USERNAME=xmlDoc.SelectSingleNode("//username").InnerText;
mu.LASTLOGINIP=xmlDoc.SelectSingleNode("//userip").InnerText;
mu.MEMBEREMAIL=xmlDoc.SelectSingleNode("//email").InnerText;
mu.QUESTION=xmlDoc.SelectSingleNode("//question").InnerText;
mu.ANSWER=xmlDoc.SelectSingleNode("//answer").InnerText;
string sex=xmlDoc.SelectSingleNode("//gender").InnerText;
ApiClass.WriteLog("性别是|"+sex+"|");
if((!Common.ValidateUtil.isNumeric(sex))||sex==String.Empty)
{
mu.MEMBERSEX=0;
}
else
{
mu.MEMBERSEX=Convert.ToInt32(sex);
}
mu.ISDELETED=false;
mu.ISACTIVE=true;
mu.ISLOCK=false;
mu.JOINDATE=DateTime.Now;
mu.MEMBERNAME=xmlDoc.SelectSingleNode("//truename").InnerText;
mu.MEMBERBIRTHDAY=xmlDoc.SelectSingleNode("//birthday").InnerText;
mu.MEMBERBP=xmlDoc.SelectSingleNode("//telephone").InnerText;
mu.MEMBERADDR=xmlDoc.SelectSingleNode("//address").InnerText;
return mu;
}
public bool IsReusable
{
get
{
return true;
}
}
#endregion
}
}