Live Chat Icon For mobile
Live Chat Icon

How can we convert an ASP.NET page to HTML?

Platform: ASP.NET| Category: Custom Controls

We can use the following codings to convert the ASP.NET page to HTML page,

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Net;
publicpartialclass_Default : System.Web.UI.Page
{
	WebRequest mywebRequest;
	WebResponse mywebResponse;
	StreamReader sr;
	string strHTML;
	StreamWriter sw;
	protected void Page_Load(object sender, EventArgs e)
	{
		mywebRequest = WebRequest.Create('http://www.syncfusion.com/Corporate/default.aspx');
		mywebResponse = mywebRequest.GetResponse();
		sr = new StreamReader(mywebResponse.GetResponseStream());
		strHTML = sr.ReadToEnd();
		sw = File.CreateText(Server.MapPath('temp.html'));
		sw.WriteLine(strHTML);
		sw.Close();
	}
}

Now the Html Code of (‘http://www.syncfusion.com/Corporate/default.aspx’) will be placed in the application folder by the name temp.html

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.