通过 Web 服务返回大大小字符串时出现 IIS 错误
本文关键字:IIS 错误 Web 服务 返回 通过 字符串 | 更新日期: 2023-09-27 18:34:36
我想通过网络服务返回图像,所以我尝试将数据库中的图像转换为字节,然后从字节转换为 base64 字符串并将其返回到网络服务,我已经完成了一半,但由于字符串大小或其他方面的限制,我无法返回整个字符串希望?
<%@ 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;
}
}
web.config 未修改。
帮我检索整个base64字符串。
我的理解是您已将图像作为二进制存储在数据库中,并且现在想检索它。
如果需要,请检查此链接插入和检索二进制图像