请问新闻系统如何生成HTML。
网上虽然有,但没有说到具体。
网上虽然有,但没有说到具体。
解决方案 »
- 后台生成新图片
- 请问以下dll哪个可以 用于打开摄像头???
- |M| 幕白兄在吗?问我那个网页掉用本地应用程序的问题
- 问个简单的格式问题
- C#技术群!我们不缺菜鸟,宁缺毋滥!希望你有一定的开发经验或相关技术专长!
- 有一个关于asp.net服务器控件的保存状态的问题(2)
- 如何禁用DataGrid???
- 跪求,怎样将信息回传回某个页面中的指定编辑框,并且不能刷新该页面的其他控件内容!!用C#配javascript最好!!
- 图片存入服务器
- 个伟大虾帮忙:关于页面对应的aspx.cs的继承的问题!
- |M| ------迷惑中----- 我正想要学习ajax 但xiahouwen(武眉博<活靶子.NET>) 建议我学Altas 但好像Altas是用在2.0的.但我只学了1.1 请问
- vs.net2005中asp.net请问怎么设置全局变量!,在线等待
<news>
<title></tile>
<body></body>
</news>
就行了 这个很容易生成
XLST来负责显示 并且可以随时更换显示样式http://www.mscenter.edu.cn/
http://www.alumni.sdu.edu.cn/web2006/
你可以用免费的组建
www.urlrewrite.net 上面就有开源的组件
//生成HTML页
public static bool WriteFile(string strText,string strContent,string strAuthor)
{
string path = HttpContext.Current.Server.MapPath("/news/");
Encoding code = Encoding.GetEncoding("gb2312");
// 读取模板文件
string temp = HttpContext.Current.Server.MapPath("/news/text.html");
StreamReader sr=null;
StreamWriter sw=null;
string str="";
try
{
sr = new StreamReader(temp, code);
str = sr.ReadToEnd(); // 读取文件
}
catch(Exception exp)
{
HttpContext.Current.Response.Write(exp.Message);
HttpContext.Current.Response.End();
sr.Close();
} string htmlfilename=DateTime.Now.ToString("yyyyMMddHHmmss")+".html";
// 替换内容
// 这时,模板文件已经读入到名称为str的变量中了
str =str.Replace("ShowArticle",strText); //模板页中的ShowArticle
str = str.Replace("biaoti",strText);
str = str.Replace("content",strContent);
str = str.Replace("author",strAuthor);
// 写文件
try
{
sw = new StreamWriter(path + htmlfilename , false, code);
sw.Write(str);
sw.Flush();
}
catch(Exception ex)
{
HttpContext.Current.Response.Write(ex.Message);
HttpContext.Current.Response.End();
}
finally
{
sw.Close();
}
return true; 此函数放在Conn.CS基类中了
在添加新闻的代码中引用 注:工程名为Hover
程序代码
if(Hover.Conn.WriteFilethis.Title.Text.ToString),this.Content.Text.ToString),this.Author.Text.ToString)))
{
Response.Write("添加成功");
}
else
{
Response.Write("生成HTML出错!");
} -------------------------------------------------------------------------
模板页Text.html代码
-------------------------------------------------------------------------
biaoti contentauthor
url rewriting只是为ASPX穿个马甲而已,理论速度比aspx慢,IIS多了个穿马甲的工作。