在下面的代码我正在处理wcf服务我上传一个文本文件或pdf文件,当我尝试上传图像文件时它会上传错误“远程服务器返回了一个意外的响应:(413)请求实体太大“。请任何人帮我解决问题。
File.aspx.cs
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);
}
Webconfig
<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" />