Wednesday, 3 November 2021

Read HTML File in C#

11/03/2021 - By Pranav Singh 0

 In this article i will show you how you can read a html file content in string variable using c#.net. This trick to read html file using c#.net can be used in Asp.net core, MVC and asp.net application, Console application. 

This article will cover following topics:

  • Read HTML file from folder C#
  • How to read html file line by line in c#
  • How to read html file in asp.net using c#
  • How to convert html file to string in c#
  • Read html file in net core
  • How to read web page content in c#
  • Blazor read html file

Now first we will create a HTML file and add some content.

Read HTML File in C#

Now for this article first we will create a new application and add the below code into your application.

  public ActionResult Index()

        {

            string content = System.IO.File.ReadAllText(Server.MapPath("~/HtmlFile/TestHtmlFile.html"));

            return View();

        }

 In above code i have read the file on a path.

Read HTML File in C#

Now run the application and to check the output.

Read HTML File in C#

Now check the detail output.

Read HTML File in C#


Tags:
About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top