下载并保存aspx页面 [英] Download and save aspx page
本文介绍了下载并保存aspx页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我救aspx页面为HTML它在我的本地机器的工作,但在服务器上发布后,其显示出的访问路径被拒绝......我试图让访问权限,那么也不起作用错误..任何人都可以用它帮助吗?或者是有任何其他方式保存在C#asp.net页面?...
I saved aspx page as html it worked in my local machine but after published on the server its showing an error that "the access to the path is denied"... I tried giving access permission then also it doesn't work.. can anyone help with it? or else is there any other way to save the page in C# asp.net?...
string url=HttpContext.Current.Request.Url.AbsoluteUri;
string sHtml="";
HttpWebRequest request;
HttpWebResponse response=null;
Stream stream=null;
request=HttpWebRequest)WebRequest.Create(url);
response=(HttpWebResponse)request.GetResponse();
stream=response.GetResponseStream();
StreamReader sr=new StreamReader(stream,System.Text.Encoding.Default);
sHtml=sr.ReadToEnd();
string path=Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string textfilename=TextBox1.Text;
string getpath=path+"\\"+textfilename+".html";
File.WriteAllText(getpath,sHtml);
if(stream!=null)stream.Close();
if(response!=null)response.Close();
谢谢..
推荐答案
如果您需要保存文件,用它来获取应用程序的路径。
If you need to save a file use this to get the application path
Server.MapPath(@"filename.txt");
试试这个,因为当你只在您尝试访问Microsoft.Net文件夹中的Web服务器写入的文件名。
Try this because when you only write the filename at an web server you are trying to access to a Microsoft.Net folder.
这篇关于下载并保存aspx页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文