zoukankan      html  css  js  c++  java
  • Discuz!NT与asp.net整合集成实例教程

    由于项目需要一个论坛,本来有CS的,在.net下很出名的国外开源论坛。但为了适应国内的风气,最后选用在国内如日中天的Discuz!NT。
    将Discuz与asp.net开发的网站整合,有很多人已经完成了。

    但在网上没有找到较详细的描述。方法倒是有很多种。

    在此,我就将此次经历写出来,希望对您有用。

    在看过这篇文章

    和这篇文章

    我顿悟了...

    按上述文章的描述,先按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, false10"");
            }

            
    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://four-corner.appspot.com/ 

  • 相关阅读:
    第一章 数据库概论
    规范化
    qt mysql驱动问题解绝
    linux文件系统软链接硬链接
    linux命令总结
    shell应用技巧
    如何使滚动条保持在页面底部
    地图定位问题汇总
    webpack基本用法
    git异常操作解决办法合集
  • 原文地址:https://www.cnblogs.com/meta/p/1600015.html
Copyright © 2011-2022 走看看