Hi ramco1917,
First get the URL by deserialize and get the url.
Then you need to use a WebClient class for reading the url the byte data and use the byte to download the file.
Please refer below sample.
Json
{
"status": true,
"data": "https://nimubs-assets.s3.amazonaws.com/manifest/20221226214955-57.pdf"
}
Namespaces
C#
using System.IO;
using System.Net;
using System.Web.Script.Serialization;
VB.Net
Imports System.IO
Imports System.Net
Imports System.Web.Script.Serialization
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
string json = File.ReadAllText(Server.MapPath("~/json.json"));
JavaScriptSerializer serializer = new JavaScriptSerializer();
Root root = serializer.Deserialize<Root>(json);
using (WebClient webClient = new WebClient())
{
byte[] bytes = webClient.DownloadData(root.data);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(root.data));
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}
}
public class Root
{
public bool status { get; set; }
public string data { get; set; }
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim json As String = File.ReadAllText(Server.MapPath("~/json.json"))
Dim serializer As JavaScriptSerializer = New JavaScriptSerializer()
Dim root As Root = serializer.Deserialize(Of Root)(json)
Using webClient As WebClient = New WebClient()
Dim bytes As Byte() = webClient.DownloadData(root.data)
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" & Path.GetFileName(root.data))
Response.BinaryWrite(bytes)
Response.Flush()
Response.End()
End Using
End Sub
Public Class Root
Public Property status As Boolean
Public Property data As String
End Class
Screenshot