C# 远程服务器返回意外响应:(413)Wcf服务中的请求实体太大错误
在下面的代码中,我正在使用wcf服务上载文本文件或pdf文件,当我尝试上载图像文件时,它会引发错误“远程服务器返回意外响应:(413)请求实体太大”。请任何人帮助我解决此问题 File.aspx.csC# 远程服务器返回意外响应:(413)Wcf服务中的请求实体太大错误,c#,wcf,C#,Wcf,在下面的代码中,我正在使用wcf服务上载文本文件或pdf文件,当我尝试上载图像文件时,它会引发错误“远程服务器返回意外响应:(413)请求实体太大”。请任何人帮助我解决此问题 File.aspx.cs public void FileUpload(string FilePath, string FolderName) { FileServiceClient fileTranz = new FileServiceClient();
public void FileUpload(string FilePath, string FolderName)
{
FileServiceClient fileTranz = new FileServiceClient();
var fileContent = File.ReadAllBytes(FilePath);
FileInfo info = new FileInfo(FilePath);
string filename = info.Name.ToString();
var fileDto = new FileDto
{
FileName = filename,
FileSize = fileContent.Length,
Content = fileContent
};
string fileName = Path.GetFileName(FilePath);
var response = fileTranz.ServicetaxFileUpload(fileDto, fileName, "Image", sFileTransKey, FolderName);
if ((System.IO.File.Exists(FilePath)))
{
System.IO.File.Delete(FilePath);
}
}
FileService.svc.cs
public bool ServicetaxFileUpload(FileDto fileDto, string sFileName, string sFileType, string sCallFrom, string FolderName)
{
if (sCallFrom != "ttdll")
return false;
var Uploadpath = ConfigurationManager.AppSettings["HoardServer"].ToString();
Uploadpath = Uploadpath.TrimEnd("\\".ToCharArray()) + "\\PaidESI\\" + sFileName;
var DirectoryName = Path.GetDirectoryName(Uploadpath);
DirectoryInfo dInfo = new DirectoryInfo(DirectoryName);
if (!dInfo.Exists)
{
dInfo.Create();
}
if (sFileType == "Image")
{
//if (!File.Exists(Uploadpath))
File.WriteAllBytes(Uploadpath , fileDto.Content);
}
else if (sFileType == "Xml")
File.WriteAllBytes(Uploadpath , fileDto.Content);
else
File.WriteAllBytes(Uploadpath , fileDto.Content);
}
网络配置
<binding name="BasicHttpBinding_IFileService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
messageEncoding="Text">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
您的图像有多大?@edig超过800KB