error with iis while returning large size string through webservice

907 Views Asked by At

I want to return a image through webservice , so i tried to convert the image in database to byte then from byte to base64 string and return it to webservice , i am done with half the way but i could not return the whole string hope due to some restriction of string size or something else ?

<%@ WebService Language="C#" Class="Service" %>


using System;

using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
{
    public Service () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string IMAGE(string ID)
    {


        SqlConnection conn = new SqlConnection("Data Source=NEWCRISP19;Initial Catalog=masselango;Persist Security Info=True;User");
        conn.Open();
        SqlDataAdapter sdImageSource = new SqlDataAdapter();
        sdImageSource.SelectCommand = new SqlCommand("select ImageData from ImagesStore where ImageId=('" + ID + "')", conn);
        DataSet dsImage = new DataSet();
        sdImageSource.Fill(dsImage);

        byte[] blob = (byte[])dsImage.Tables[0].Rows[0][0];
        String c = Convert.ToBase64String(blob);
        //c = c.Replace(" ", "");
        return c;


    }

}

The web.config is unmodified.

help me retrieveing the whole base64 string .

1

There are 1 best solutions below

1
On BEST ANSWER

What i understood is you have stored image in database as binary and you want to retrieve it now.

If that is you want then please check this Link Insertion and Retrieval of image in binary