怎么让C#必须代码执行完成后再执行下面的代码 5
if(Request.QueryString["state"].ToString()==HttpPostAndGet.STATEINFO){///获取用户信息//我想先执...
if (Request.QueryString["state"].ToString() == HttpPostAndGet.STATEINFO)
{
///获取用户信息
//我想先执行的顺序,有时候执行的可能比较慢就会先跳入404页面 第二次进入该页面才会正常
<1>
Userinfo userInfo = new Userinfo();
userInfo = HttpPostAndGet.sendToHttp<Userinfo>("https://api.weixin.qq.com/sns/userinfo?access_token=" + InJson.access_token + "&openid=" + InJson.openid + "&lang=zh_CN", "", "GET");
<2>
if (userInfo.openid == null)
{
//如果获取的信息为空就跳入404页面
Response.Redirect("404.aspx");
}
else
{
//不为空就将数据添加到user表
string s = null;
if (userInfo.sex == 1)
{
s = "men";
}
else if (userInfo.sex == 2)
{
s = "women";
}
Red_Person person = new Red_Person { wxId = userInfo.openid, name = userInfo.nickname, headimgurl = userInfo.headimgurl, city = userInfo.city, country = userInfo.country, province = userInfo.province, sex = s, phone = "", email = "", score = 0 };
db.Red_Person.InsertOnSubmit(person);
db.SubmitChanges();
} 展开
{
///获取用户信息
//我想先执行的顺序,有时候执行的可能比较慢就会先跳入404页面 第二次进入该页面才会正常
<1>
Userinfo userInfo = new Userinfo();
userInfo = HttpPostAndGet.sendToHttp<Userinfo>("https://api.weixin.qq.com/sns/userinfo?access_token=" + InJson.access_token + "&openid=" + InJson.openid + "&lang=zh_CN", "", "GET");
<2>
if (userInfo.openid == null)
{
//如果获取的信息为空就跳入404页面
Response.Redirect("404.aspx");
}
else
{
//不为空就将数据添加到user表
string s = null;
if (userInfo.sex == 1)
{
s = "men";
}
else if (userInfo.sex == 2)
{
s = "women";
}
Red_Person person = new Red_Person { wxId = userInfo.openid, name = userInfo.nickname, headimgurl = userInfo.headimgurl, city = userInfo.city, country = userInfo.country, province = userInfo.province, sex = s, phone = "", email = "", score = 0 };
db.Red_Person.InsertOnSubmit(person);
db.SubmitChanges();
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询