Hi
I Display Multiple data Muliple view bags from multiple store procedure and Display in html page what i want when i click submit this html page data with same design i want to base 64 formate and this data i need to send other api and get this data and display to user

Rajkiran SwainRank #165 · 14.4K reputationPosted May 25, 2023, 4:38 AM EDT
Retrieve the HTML data from the HTML page or view bags in your controller action.
Convert the HTML data to a byte array using the appropriate encoding (e.g., UTF-8).
Convert the byte array to Base64 string using the
Convert.ToBase64Stringmethod.Send the Base64 string to the desired API using an HTTP request (e.g., using the
HttpClientclass).Here's an example of how you can achieve this:
using System; using System.Net.Http; using System.Text; using System.Web.Mvc; namespace YourNamespace.Controllers { public class YourController : Controller { public ActionResult YourAction() { // Retrieve HTML data from view bags or HTML page string htmlData = ViewBag.HtmlData; // Replace with your own code to retrieve HTML data // Convert HTML data to byte array byte[] htmlBytes = Encoding.UTF8.GetBytes(htmlData); // Convert byte array to Base64 string string base64Data = Convert.ToBase64String(htmlBytes); // Send the Base64 string to the other API SendDataToOtherAPI(base64Data); // Replace with your own code to send data to the API // Optionally, pass the Base64 string to the view to display it ViewBag.Base64Data = base64Data; return View(); } private void SendDataToOtherAPI(string base64Data) { // Create an instance of HttpClient using (var httpClient = new HttpClient()) { // Set the API endpoint URL string apiUrl = "https://example.com/api/endpoint"; // Replace with your API endpoint URL // Create an HTTP content with the Base64 data var content = new StringContent(base64Data, Encoding.UTF8, "application/base64"); // Send a POST request to the API endpoint var response = httpClient.PostAsync(apiUrl, content).Result; // Check the response status and handle it accordingly if (response.IsSuccessStatusCode) { // Data sent successfully } else { // Error occurred while sending data } } } } }Thulasiram pakalaRank #1,835 · 808 reputationPosted May 25, 2023, 5:22 AM EDT
Multple view bags are having 20 viewbags data i display so all i need to display view page this data i need to convert pdf and this pdf convert ase 64 and need to sent how
Thulasiram pakalaRank #1,835 · 808 reputationPosted May 25, 2023, 7:25 AM EDT
Persional Details,
Family details,
Income details like
model.Income ,model.Address ,model.Family like diffret model class i bind one html page when i click submit i need to submit this hole page data like pdf this data convert base 64 and need to send api in this how