views:

23

answers:

0

Hi All

I am getting following error while uploading file in asp.net.

"Length = 'stream.Length' threw an exception of type 'System.NotSupportedException'"

I have already configured httpRuntime in config as follow:-

<httpRuntime maxRequestLength="2097151" executionTimeout="7200" />

This error occurred usually when i tried to upload file more than 100 Mb.

My using WebRequest.GetRequestStream() for getting stream. Code is as follow:-

 public Stream GetRequestStream()
        {
            AuthorizeIfNecessary();
            return WebRequest.GetRequestStream();
        }


        public void PerformWithRequestStream(Action<Stream> action)
        {
            using (Stream stream = GetRequestStream())
                action(stream);

            GetResponse().Close();
        }

Please help to sort out this issue.

Thanks