日期:2014-05-19  浏览次数:20542 次

asp.net文件怎样可以生成.html文件(高手请进!)
请问:一个动态的.aspx文件怎样可以生成一个静态的.html文件?谢谢啦!

------解决方案--------------------
Request.SaveAs( "c:\\temp\\xxx.htm ", True)


------解决方案--------------------
Request.SaveAs( "c:\\temp\\xxx.htm ", true);


------解决方案--------------------
using System.Net;

private string GetContentFromUrll(string _requestUrl)
{
string _StrResponse = " ";
HttpWebRequest _WebRequest = ( HttpWebRequest )WebRequest.Create( _requestUrl );
_WebRequest.Method = "GET ";
WebResponse _WebResponse = _WebRequest.GetResponse();
StreamReader _ResponseStream = new StreamReader( _WebResponse.GetResponseStream(), System.Text.Encoding.GetEncoding( "gb2312 "));
_StrResponse = _ResponseStream.ReadToEnd();
_WebResponse.Close();
_ResponseStream.Close();
return _StrResponse;
}
//--根据上面的函数获取相应地址的文件的内容
//--然后用下面的喊出写出文件即可
/// <summary>
/// 创建/写入文件内容
/// </summary>
/// <param name= "FileName "> 文件名(默认当前目录/包含路径) </param>
/// <param name= "FileContent "> 文件内容 </param>
/// <param name= "act "> 改写(false)/追加到文件尾部(true) </param>
/// <returns> 返回bool </returns>
public static bool IO_CreatTextFile(string FileName, string FileContent, bool act)
{
try
{
StreamWriter writer1 = new StreamWriter(FileName, act, Encoding.Default);
writer1.Write(FileContent);
writer1.Close();
}
catch
{
return false;
}
return true;
}
------解决方案--------------------
if (Request.QueryString[ "toHtml "] == null) { System.IO.StringWriter sw = new System.IO.StringWriter(); Server.Execute( "default.aspx?toHtml=1 ",sw); System.IO.StreamWriter stremwriter = new System.IO.StreamWriter(Server.MapPath( "aa.html ")); stremwriter.Write(sw.ToString() ); stremwriter.Close(); Response.Redirect( "aa.html "); }
------解决方案--------------------
看看web.config <globalization requestEncoding= "utf-8 " responseEncoding= "utf-8 "/>
------解决方案--------------------
Encoding code = Encoding.GetEncoding( "gb2312 ");
StreamWriter sw = new StreamWriter(Server.MapPath(gpath),false,code);
string last = readText;
last = readText.Replace( " Script ",script);
try
{
sw.Write(last);
sw.Flush();
sw.Close();
}
catch (Exception ee)
{
Page.Response.Write( "Exception : " + ee.ToString());
sw.Close();
}
finally
{
sw.Close();
}
这就生成拉,就向你生成普通文件一样阿,不过你要先建立模板性的文件,读取他,然后在替换一些内容
------解决方案--------------------
www.tj126.net
------解决方案--------------------
误认子弟呀。很简单: