1

我试图在我的 web api web 服务中接收一个 base64 字符串(这是一个图像)。

我遇到的问题是字符串的长度,有没有办法可以设置传入字符串的限制以允许大尺寸的字符串?该字符串已被编码以供 url 使用。据我所知,这是我的问题。现在,如果我调用该函数,它会给我一个 404 错误。但是,如果我删除 base64string 并只放入一个普通字符串,它就可以工作。

这是我的功能

    public int userLogin(string identifier, string name, string hometown, string photo)
    {
        da = new SqlDataAdapter();
        ds = new DataSet();
        command = new SqlCommand("p_userLogin", connection);
        command.Parameters.AddWithValue("@userInfo", identifier);
        command.Parameters.AddWithValue("@name", name);
        command.Parameters.AddWithValue("@hometown", hometown);
        command.Parameters.AddWithValue("@photo", photo);
        command.CommandType = CommandType.StoredProcedure;
        da.SelectCommand = command;
        da.Fill(ds);
        int userID = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
        return userID;
    }

这是我要发送的 base 64 字符串

%2F9j%2F4AAQSkZJRgABAgAAAQABAAD%2F%2FgAEKgD%2F4gIcSUNDX1BST0ZJTEUAAQEAAAIMbGNtcwIQAABtbnRyUkdCIFhZWiAH3AABABkAAwApADlhY3NwQVBQTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLWxjbXMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAApkZXNjAAAA%2FAAAAF5jcHJ0AAABXAAAAAt3dHB0AAABaAAAABRia3B0AAABfAAAABRyWFlaAAABkAAAABRnWFlaAAABpAAAABRiWFlaAAABuAAAABRyVFJDAAABzAAAAEBnVFJDAAABzAAAAEBiVFJDAAABzAAAAEBkZXNjAAAAAAAAAANjMgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0ZXh0AAAAAEZCAABYWVogAAAAAAAA9tYAAQAAAADTLVhZWiAAAAAAAAADFgAAAzMA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8AnYN%2BoCoX5k0IxmM%2F7BlVolzfNjP%2FxAAaEQEAAwEBAQAAAAAAAAAAAAABABEhEDEg%2F9oACAECEQE%2FEIPAUuBY%2BKjAXA0imzXztyoRE7MjwdTJdTJMqIOS%2Bf%2FEACARAAIABQUBAAAAAAAAAAAAAAABEBEhMeEgcZGh8EH%2F2gAIAQERAT8QiwRp1hKLsOqYregkJ%2FsCnMbIlBeeQ6bd4HMt7gSlt3g294Ni5wf%2FxAAnEAEAAgIABgICAgMAAAAAAAABABEhMUFRYXGBkRDwIKGxwdHh8f%2FaAAgBAAABPxD8bHBvyAtgSxubWaeyjq3OWmhRcWa5BGuE702QdPYj5fh%2BWLBlL3GAokoQq7dXgYYJuyUWKCqNrMBct19ib7rYxnGmY9RPIjrFx7qNJlNYUH8x%2FB3OmW8%2FjJkUoBss3jSnmAoWwqwwvHHq6hStcYl5NWiZyjeWGrZBwArVeX3DtqbgEUuQIPEflgkW35Ciyo7Zf1cIFq8yPv8AzGvE029aczugohlJgKoQa78%2FEfik06SiWQbYMy7BGLHsHL4gMPQBHKEsC1PEqUcDUxvtcBUBzdDnAkkL4UwK4bOJu%2Be%2Fhm0Uxt5VHo3t5%2B2IQxVlnJLe4J1imuUmbyK8C%2BssiZbu8VuFIDhX79QPiMEE2tf8QNTVZsL61sHKznGcZ7JWSigchks6B6VCjzgL6NBh8RtB77jjuODlgMIAlDSf1cGoiTwUbXGsNrdpqgAKcRoBCmkrYDTV3DM1O5T2Fd25g4SuNI9OxqACkmq5A4jCbarwqbiXHdl%2Fo8RcALYRTkcwgTUNq9x3BYURVZikFM1dPgiGZ1v%2FAHxRft94XAh3ojx6zGRwwGliiTcA5LTESZAtbwDiXeAq%2FwC8QFpj75gF%2Bn5hS%2Bn5n%2F%2FZ

对此的任何意见将不胜感激。

4

1 回答 1

0

我不知道你是否得到答案,因为问题已经发布了很长时间。

我也遇到了同样的问题,使用下面的链接解决了我的问题可能会帮助您找到答案@Ken

ASP.NET Web API 不允许冗长的 base64 URI

于 2017-06-27T07:08:31.300 回答