TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
How To Download Json String From URL Using Web Client And Convert Json To Datatable In ASP.NET
Nikhil Sangani
Aug 07
2016
Code
10.7
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
string str =
"type your json url here"
;
WebClient webClient =
new
WebClient();
if
(webClient ==
null
) {
webClient =
new
WebClient();
}
else
{
webClient.Dispose();
webClient =
null
;
webClient =
new
WebClient();
}
DataTable JsonDataTable =
new
DataTable();
//Set Header
webClient.Headers[
"User-Agent"
] =
"Mozilla/4.0 (Compatible; Windows NT 5.1; MSIE 6.0) (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
;
//Download Content
string JsonSting = webClient.DownloadString(str);
//Convert JSON to Datatable
JsonDataTable = (DataTable) JsonConvert.DeserializeObject(JsonSting, (
typeof
(DataTable)));
JsonDataTable.TableName =
"JSON_MAST"
;
Json String
Web Client
Convert Json
Datatable
ASP.NET