Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm facing problem when I'm trying to upload large file i.e. more than 4 mb it is throwing me an error.
unterminated string or constant.
AttPages/frmAttch.aspx?hsTable=hsAttach'

I have included following line of code in my web.config file
<httpRuntime executionTimeout="3600" maxRequestLength="65536"/>

but of no use in my case.

when i'm using attachment webservice which is installed on server(windows server 2003), than I'm able to upload more even more than 60mb.
but when i'm using webservice which is installed on my local m/c (windows vista), than not able to upload more than 4mb.
In both cases website and its config file is same only service installation place is diffrent but web service is same.
Is there any machine related config is required which is already there on server and i dont have it on my local machin.
or kind of restrictions.

can any one suggest me what could be the problem.

Below is the code snippets of web service.
public String AttachFile(string strFolderPath, string strFile, byte[] fileBuffer)
{
FileStream _FileStream = null;
DirectoryInfo _Folder = new DirectoryInfo(strFolderPath);
if (!_Folder.Exists)//Checks if the folder exists in the given path else creates it.
{
_Folder.Create();
_Folder.SetAccessControl(new System.Security.AccessControl.DirectorySecurity(strFolderPath, System.Security.AccessControl.AccessControlSections.Owner));
}
try
{
_FileStream = new FileStream(strFolderPath + "\\" + strFile, FileMode.Create);
_FileStream.Write(fileBuffer, 0, fileBuffer.Length);
_FileStream.Close();
return "True";
}
catch (Exception Ex)
{
return Ex.Message;
}

}
with following webconfig file.
XML
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <appSettings />
    <connectionStrings />
    <system.web>
<authentication mode="Windows" />
<identity impersonate="true" userName="astral\EERADMIN" password="pass@123" />

<customErrors mode="Off" />
<sessionState timeout="1440" />
<httpRuntime maxRequestLength="102400" executionTimeout="240" />
        <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        -->
        <compilation debug="true" defaultLanguage="c#" />
        <roleManager enabled="true" />
        <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
  <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
    </system.web>
    <system.webServer>
        <security>
            <authentication>
                <anonymousAuthentication enabled="true" />
            </authentication>
        </security>
        <directoryBrowse enabled="true" />
    </system.webServer>
</configuration>
Posted
Updated 11-May-11 21:06pm
v4

Change your maxrequestlength to 5mb, and see if that doesn't help.

Or, you could send the file in chunks of 64K (which is your current request length).

Or, you could rewrite your web service.

Or, you could use FTP instead.

Or, you could try using WebClient.UploadFile.

It's your code, and your project. We can only suggest solutions.
 
Share this answer
 
v3
Comments
fjdiewornncalwe 11-May-11 9:22am    
Excellent solution. I just had to do this with a web service yesterday, in fact. +5
Nirbhay Giri 12-May-11 3:23am    
thnx but,
I need to do it with our existing webservice only.
need to know why its working at one place and why not another place.
Hello Nirbhay,

There is no problem in your web.config. only problem that could be is that you are using web service to attach documents. Web service has Limitation that you can not pass data exceed quantity, because of its SOAP protocol.


Hope this will help you.

Pankaj
 
Share this answer
 
Comments
Nirbhay Giri 12-May-11 3:24am    
thnx,
Did not get. how to check the SOAP protocol limitation?
Nirbhay Giri 15-Mar-12 13:24pm    
what is the maximum size that can be attached because after searching on internet I got the answer saying that There is no max size but browser has timeout.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900