2
Vote

Captcha renders, but exception is thrown and Refresh link does not render.

description

Here's the exception that's thrown:
System.NotSupportedException crossed a native/managed boundary
  HResult=-2146233067
  Message=Specified method is not supported.
  Source=System.Web
  StackTrace:
       at System.Web.HttpResponseStream.get_Position()
       at System.Drawing.UnsafeNativeMethods.ComStreamFromDataStream.Seek(Int64 offset, Int32 origin)
  InnerException: 

comments

VVS0205 wrote Aug 6, 2014 at 2:03 AM

Hi,
Can you provide more information about the problem, or could you please give a demo project to demonstrate this issue?
I found the same problem on the Microsoft site, the page is not available so I added a link to the cache, maybe it will be helpful to you.

AlexanderSimonov wrote Dec 12, 2014 at 11:56 AM

@VVS0205, the exception occurs from https://captchamvc.codeplex.com/SourceControl/latest#CaptchaMvc(Mvc 3)/Infrastructure/DefaultCaptchaBuilderProvider.cs, WriteCaptchaImage method, at line
bitmap.Save(response.OutputStream, ImageFormat.Gif).

To fix exception you should replace response.OutputStream with MemoryStream instance and then copy bytes from MemoryStream to response.Outputstream.

VVS0205 wrote Dec 12, 2014 at 12:58 PM

Thank you Alexander,
I will fix it in the next version.