请问用asp.net生成html页面怎么调用?

解决方案 »

  1.   

    private void SaveBuliteHtml(int BuliteID, string mtitle, string mAuthor, string mKeywords, string mDescription, string SysTelInfoURL)
        {
            //*****保存文件路径
            string SaveFilePath = Server.MapPath("../UpLoadFiles/HtmlPage/");        if (Directory.Exists(SaveFilePath) == false)
            {
                //****创建文件夹
                Directory.CreateDirectory(SaveFilePath);
            }        //****生成文件名
            string BuliteFileName = DateTime.Now.ToString("yyyyMMdd").ToString() + Guid.NewGuid().ToString().Substring(0, 3) + BuliteID.ToString();        //****构造文件生成的路径
            string FilePath = System.IO.Path.GetDirectoryName(SaveFilePath) + @"\" + BuliteFileName + @".html";        FileInfo fi = new FileInfo(FilePath);        //StreamWriter sw = fi.AppendText();
            FileStream mFileStream = fi.Create();        StringBuilder strApp = new StringBuilder();        //****保存内容信息
            strApp.Append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n");
            strApp.Append("<html>\r\n");
            strApp.Append("<head>\r\n");
            strApp.Append("<script language=\"javascript\" type=\"text/javascript\">\r\n");
            strApp.Append("<!--\r\n");
            strApp.Append("function RecortURL()\r\n");
            strApp.Append("{\r\n");
            strApp.Append(" window.location.href=\"" + SysTelInfoURL + "\"\r\n");
            strApp.Append("}\r\n");
            strApp.Append("-->\r\n");
            strApp.Append("</script>\r\n");
            strApp.Append("<title>" + mtitle + "</title>\r\n");
            strApp.Append("<meta name=\"Generator\" content=\"EditPlus\">\r\n");
            strApp.Append("<meta name=\"Author\" content=\"" + mAuthor + "\">\r\n");
            strApp.Append("<meta name=\"Keywords\" content=\"" + mKeywords + "\">\r\n");
            //strApp.Append("<meta name=\"Description\" content=\"" + mDescription + "\">\r\n");
            strApp.Append("</head>\r\n");
            strApp.Append("<body onload=\"RecortURL();\">\r\n");
            strApp.Append("<div>");
            strApp.Append("<p>");
            strApp.Append("<font size=2>");
            strApp.Append(mDescription.Replace(" ","&nbsp;").Replace("\r\n","<br>"));
            strApp.Append("</font>");
            strApp.Append("</p>");
            strApp.Append("</div>");
            //strApp.Append("<iframe width=\"1004\" height=\"2288\" src=\"" + SysTelInfoURL + "\" frameborder=\"no\" border=\"0\" marginwidth=\"0\" marginheight=\"0\"  scrolling=\"no\"></iframe>\r\n");
            strApp.Append("</body>\r\n");
            strApp.Append("</html>");        byte[] mbypte = System.Text.Encoding.Default.GetBytes(strApp.ToString());        //*****写入文件内容
            mFileStream.Write(mbypte, 0, mbypte.Length);        //****关闭文件流
            mFileStream.Close();        //****保存成功以后清空以前数据
            strApp.Length = 0;
        }