现在公司打算建一个电子商务网站,要写需求,想请教下各位,像这样的网站有没有必要做HTML静态页面,前面我听说现在搜索引擎对于动态页面的收录也挺好的,没有必要做,而商城网站做了静态以后管理起来比较麻烦。各位给点意见哈。

解决方案 »

  1.   

    生成HTML
    public static bool CreatHtmlPage(string[] strNewsHtml, string[] strOldHtml, string strModeFilePath, string strPageFilePath)
            {
                bool Flage = false;
                StreamReader ReaderFile = null;
                StreamWriter WrirteFile = null;
                //修改mode.htm到inc目录下
               strModeFilePath = "../inc/" + strModeFilePath;
                string FilePath = HttpContext.Current.Server.MapPath(strModeFilePath);
                Encoding Code = Encoding.GetEncoding("gb2312");
                string strFile = string.Empty;
                try
                {
                    ReaderFile = new StreamReader(FilePath, Code);
                    strFile = ReaderFile.ReadToEnd();            }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    ReaderFile.Close();
                }
                try
                {
                    int intLengTh = strNewsHtml.Length;
                    for (int i = 0; i < intLengTh; i++)
                    {
                        strFile = strFile.Replace(strOldHtml[i], strNewsHtml[i]);
                    }
                    WrirteFile = new StreamWriter(HttpContext.Current.Server.MapPath(strPageFilePath), false, Code);
                    WrirteFile.Write(strFile);
                    Flage = true;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {                WrirteFile.Flush();
                    WrirteFile.Close();
                }
                return Flage;
            }
            public static bool UpdateHtmlPage(string[] strNewsHtml, string[] strStartHtml, string[] strEndHtml, string strHtml)
            {
                bool Flage = false;
                StreamReader ReaderFile = null;
                StreamWriter WrirteFile = null;
                string FilePath = HttpContext.Current.Server.MapPath(strHtml);
                Encoding Code = Encoding.GetEncoding("gb2312");
                string strFile = string.Empty;
                try
                {
                    ReaderFile = new StreamReader(FilePath, Code);
                    strFile = ReaderFile.ReadToEnd();            }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    ReaderFile.Close();
                }
                try
                {
                    int intLengTh = strNewsHtml.Length;
                    for (int i = 0; i < intLengTh; i++)
                    {
                        int intStart = strFile.IndexOf(strStartHtml[i]) + strStartHtml[i].Length;
                        int intEnd = strFile.IndexOf(strEndHtml[i]);
                        string strOldHtml = strFile.Substring(intStart, intEnd - intStart);
                        strFile = strFile.Replace(strOldHtml, strNewsHtml[i]);
                    }
                    WrirteFile = new StreamWriter(FilePath, false, Code);
                    WrirteFile.Write(strFile);
                    Flage = true;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {                WrirteFile.Flush();
                    WrirteFile.Close();
                }
                return Flage;
            }伪静态也行。
    URL重写