wangfakun 发表于 2011-11-29 11:39

C#.net实现参数隐私安全

实现的C#.net代码:

    using System;

    using System.Collections;

    using System.ComponentModel;

    using System.Drawing;

    using System.Web;

    using System.Web.SessionState;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.Web.UI.HtmlControls;

    using System.IO;

    using System.Text;

    using System.Text.RegularExpressions;

    using System.Data.SqlClient;

    using System.Configuration;

    //导入自定义的类库

    using _3Layer.DataLayer.DataCommon;

    using _3Layer.DataLayer.DataCommon.DataAccess;

    using Library.ClassLibrary.Crypt.DES;

    namespace CHONGCHONG.XML

    public class RenderingXML : System.Web.UI.Page

    {

    /// <summary>

    /// 从数据库预生成XML数据源

    /// </summary>

    private void PreRenderXML()

    {

    string strSQL = "select语句略去……;

    myDataLayer.Open();

    RenderingXml="<?xml version='1.0'

    encoding='gb2312'?>\r\n";

    RenderingXml+="<xml>\r\n";

    try

    {

    System.Data.SqlClient.SqlDataReader myDR

    = (SqlDataReader)myDataLayer.ExecuteReader( strSQL );

    while(myDR.Read())

    {

    RenderingXml+="<TreeNode id='"+myDR["BoardID"]+"'>\r\n";

    RenderingXml+="<NodeText>"+myDR["BoardName"]+"</NodeText>\r\n";

    RenderingXml+="<title>"+myDR["Title"]+"</title>\r\n";

    RenderingXml+="<NodeUrl>"+EncodeHTML

    ( EncodeParameter( myDR["Link"].ToString() ) )+"</NodeUrl>\r\n";

    RenderingXml+="<child>"+myDR["children"]+"</child>\r\n";

    RenderingXml+="<target>"+myDR["Target"]+"</target>\r\n";

    RenderingXml+="</TreeNode>\r\n";

    }

    }

    catch(System.Data.SqlClient.SqlException ee)

    {

    return ;

    }

    finally

    {

    myDataLayer.Close() ;

    }

    RenderingXml+="</xml>";

    byte[] bytResult = Encoding.Default.GetBytes( RenderingXml ) ;

    Response.ContentType = "text/xml" ;

    Response.BinaryWrite( bytResult ) ;

    }

    /// <summary>

    /// Description:加密路径参数

    /// </summary>

    /// <param name="sourParameter"></param>

    /// <returns></returns>

    private string EncodeParameter( string sourParameter )

页: [1]
查看完整版本: C#.net实现参数隐私安全