asp.net與Discuz!NT整合集成實例教程
更新時間:2009年11月11日 00:58:52 作者:
由于項目需要一個論壇,本來有CS的,在.net下很出名的國外開源論壇。但為了適應國內的風氣,最后選用在國內如日中天的Discuz!NT。將Discuz與asp.net開發(fā)的網站整合,有很多人已經完成了。
但在網上沒有找到較詳細的描述。方法倒是有很多種。
在此,我就將此次經歷寫出來,希望對您有用。
在看過這篇文章
http://chabaoo.cn/article/20851.htm
和這篇文章
http://chabaoo.cn/article/20850.htm
按上述文章的描述,先按discuz!nt的用戶指南,在windows 2003下安裝好論壇。
并以admin進去,添加apikey等。
然后用VS2008新建一項目,添加toolkit.dll和json的引用。
好了, 如果你認真看過上述文章,再加上,我這兒貼的一點代碼,應該可以完成了。
在項目中注冊新用戶時,也同時調用論壇的用戶注冊,這樣就同步注冊了。至于刪除用戶,似乎Discuz!NT沒有提供API,可以在項目中刪除用戶時,再直接去刪除Discuz!NT的user表中的相關項。
代碼(實現了登錄和注冊)如下:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Discuz.Toolkit;
namespace IntDNT3
{
public partial class _Default : System.Web.UI.Page
{
string api_key = "c83a253f082bc671d8fbe42d485a1488";
string secret = "bdb7378cef77149adec776b1b6e92ee8";
string url = "http://localhost/";
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnValidation_Click(object sender, EventArgs e)
{
DiscuzSession ds = new DiscuzSession(api_key, secret, url);
Uri uri = ds.CreateToken();
Response.Redirect(uri.ToString());
}
protected void btnLogin_Click(object sender, EventArgs e)
{
DiscuzSession ds = new DiscuzSession(api_key, secret, url);
int uid = ds.GetUserID(tbUserName.Text);
ds.Login(uid, tbPWD.Text, false, 10, "");
}
protected void btnRegister_Click(object sender, EventArgs e)
{
DiscuzSession ds = new DiscuzSession(api_key, secret, url);
ds.Register("testa", "123123", "dafafa@51aspx.com", false);
}
}
}
在此,我就將此次經歷寫出來,希望對您有用。
在看過這篇文章
http://chabaoo.cn/article/20851.htm
和這篇文章
http://chabaoo.cn/article/20850.htm
按上述文章的描述,先按discuz!nt的用戶指南,在windows 2003下安裝好論壇。
并以admin進去,添加apikey等。
然后用VS2008新建一項目,添加toolkit.dll和json的引用。
好了, 如果你認真看過上述文章,再加上,我這兒貼的一點代碼,應該可以完成了。
在項目中注冊新用戶時,也同時調用論壇的用戶注冊,這樣就同步注冊了。至于刪除用戶,似乎Discuz!NT沒有提供API,可以在項目中刪除用戶時,再直接去刪除Discuz!NT的user表中的相關項。
代碼(實現了登錄和注冊)如下:
復制代碼 代碼如下:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Discuz.Toolkit;
namespace IntDNT3
{
public partial class _Default : System.Web.UI.Page
{
string api_key = "c83a253f082bc671d8fbe42d485a1488";
string secret = "bdb7378cef77149adec776b1b6e92ee8";
string url = "http://localhost/";
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnValidation_Click(object sender, EventArgs e)
{
DiscuzSession ds = new DiscuzSession(api_key, secret, url);
Uri uri = ds.CreateToken();
Response.Redirect(uri.ToString());
}
protected void btnLogin_Click(object sender, EventArgs e)
{
DiscuzSession ds = new DiscuzSession(api_key, secret, url);
int uid = ds.GetUserID(tbUserName.Text);
ds.Login(uid, tbPWD.Text, false, 10, "");
}
protected void btnRegister_Click(object sender, EventArgs e)
{
DiscuzSession ds = new DiscuzSession(api_key, secret, url);
ds.Register("testa", "123123", "dafafa@51aspx.com", false);
}
}
}
相關文章
深入解析.NET 許可證編譯器 (Lc.exe) 的原理與源代碼剖析
許可證編譯器 (Lc.exe) 的作用是讀取包含授權信息的文本文件,并產生一個可作為資源嵌入到公用語言運行庫可執(zhí)行文件中的 .licenses 文件2013-07-07
asp.net中MVC借助Iframe實現無刷新上傳文件實例
這篇文章主要介紹了asp.net中MVC借助Iframe實現無刷新上傳文件的方法,詳細分析了前端界面、回調函數與后臺處理的詳細流程,非常具有參考借鑒價值,需要的朋友可以參考下2014-12-12
淺談ASP.NET MVC 防止跨站請求偽造(CSRF)攻擊的實現方法
下面小編就為大家分享一篇淺談ASP.NET MVC 防止跨站請求偽造(CSRF)攻擊的實現方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-01-01

