Download and save aspx page
<p>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?...</p>

<pre><code>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();
</code></pre>

<p>Thanks..</p>
