各位大侠求求大家帮助小弟一下。。小弟如果做不出来。工作就没了。。

Lsong 2011-06-22 09:09:34
情况是这样的 要用discuz!nt做社区论坛
然后要整合登陆
前台页面是gb2312编码模式
discuz是utf-8编码模式
现在情况就是英文帐号能登陆 但需要点第2次才能登陆上中文的不能登陆
求大侠给个修改方案解决中英文都能登陆
前台代码

<form id="Form1" method="post" name="form2" runat="server" >
<div id="log" runat="server">

用户名:
<asp:TextBox ID="username" runat="server" style="height:20px;" value="用户/Email" size=12 maxLength=15></asp:TextBox>
<script language="javascript" type="text/javascript">
$('#username').focus(function () { try { if ($('#username').val() == '用户/Email') $('#username').val(''); } catch (e) { } });
$('#username').blur(function () { try { if ($('#username').val() == '') $('#username').val('用户/Email'); } catch (e) { } });
</script>
密码:<asp:TextBox ID="password" runat="server" style="height:20px;" size=12 maxLength=15 TextMode="Password"></asp:TextBox>
<asp:Button
ID="login" runat="server" Text="登陆" style="HEIGHT: 20px; CURSOR: hand"
align="absMiddle" onclick="login_Click" />




<input name="apikey" type="hidden" value="19a805310cf6cc301451cd79712ff30d">

<select name="question" id="question" change="changequestion();" tabindex="1003" style="display:none;">
<option value="0">安全提问</option>
<option onClick="loadselect_liset('question', 0, 'question','1',this.innerHTML, 1)" value="1" k_id="question">母亲的名字</option>
<option onClick="loadselect_liset('question', 0, 'question','2',this.innerHTML, 2)" value="2" k_id="question">爷爷的名字</option>
<option onClick="loadselect_liset('question', 0, 'question','3',this.innerHTML, 3)" value="3" k_id="question">父亲出生的城市</option>
<option onClick="loadselect_liset('question', 0, 'question','4',this.innerHTML, 4)" value="4" k_id="question">您其中一位老师的名字</option>
<option onClick="loadselect_liset('question', 0, 'question','5',this.innerHTML, 5)" value="5" k_id="question">您个人计算机的型号</option>
<option onClick="loadselect_liset('question', 0, 'question','6',this.innerHTML, 6)" value="6" k_id="question">您最喜欢的餐馆名称</option>
<option onClick="loadselect_liset('question', 0, 'question','7',this.innerHTML, 7)" value="7" k_id="question">驾驶执照的最后四位数字</option>
</select>



</div></from>


c#code

protected void login_Click(object sender, EventArgs e)
{
username.Text = HttpUtility.UrlEncode(username.Text, Encoding.UTF8);
password.Text = HttpUtility.UrlEncode(password.Text,Encoding.UTF8);
string pa="username="+username.Text+"&password="+password.Text;
byte[] bs=Encoding.UTF8.GetBytes(pa);
//Form1.Action = "http://club.hldhouse.com/login.aspx?referer=default.aspx";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://club.hldhouse.com/login.aspx?referer=default.aspx");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded;charset=utf-8";
request.ContentLength=bs.Length;

using (Stream reqStream = request.GetRequestStream())
{
reqStream.Write(bs,0, bs.Length);
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

}


就这部分代码大家帮我改下。。我实在是找不到门了。。。要失业了
...全文
116 点赞 收藏 8
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
编码统一
回复
子夜__ 2011-06-22
[Quote=引用 6 楼 song940 的回复:]

2楼的方法没用
4楼的方法能说的在详细吗?
[/Quote]
把前台后台的编码统一一下吧

回复
Lsong 2011-06-22
2楼的方法没用
4楼的方法能说的在详细吗?
回复
md5e 2011-06-22
最好的办法就是将你的网站全转成utf-8,要用记事本来转,要不以后还会有新的问题出现
回复
xuexiaodong2009 2011-06-22
[Quote=引用 1 楼 taomanman 的回复:]

C# code

username.Text = HttpUtility.UrlEncode(username.Text, Encoding.UTF8);
password.Text = HttpUtility.UrlEncode(password.Text,Encoding.UTF8);
string pa="usern……
[/Quote]加编码参数
回复
indusl 2011-06-22
看见这样让人垃圾的代码,我真的很忧郁啊。。。。。。。。。。。。。
回复
暖枫无敌 2011-06-22

protected void login_Click(object sender, EventArgs e)
{
string name = HttpUtility.UrlEncode(username.Text, Encoding.UTF8);
string password = HttpUtility.UrlEncode(password.Text,Encoding.UTF8);
string pa="username="+name +"&password="+password;
byte[] bs=System.Text.Encoding.GetEncoding("GB2312").GetBytes(pa);
//Form1.Action = "http://club.hldhouse.com/login.aspx?referer=default.aspx";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://club.hldhouse.com/login.aspx?referer=default.aspx");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded;charset=utf-8";
request.ContentLength=bs.Length;

using (Stream reqStream = request.GetRequestStream())
{
reqStream.Write(bs,0, bs.Length);
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

}
回复
暖枫无敌 2011-06-22

username.Text = HttpUtility.UrlEncode(username.Text, Encoding.UTF8);
password.Text = HttpUtility.UrlEncode(password.Text,Encoding.UTF8);
string pa="username="+username.Text+"&password="+password.Text;
byte[] bs=System.Text.Encoding.GetEncoding("GB2312").GetBytes(pa);

回复
相关推荐
发帖
.NET技术社区
创建于2007-09-28

5.8w+

社区成员

.NET技术交流专区
申请成为版主
帖子事件
创建了帖子
2011-06-22 09:09
社区公告
暂无公告