How do i create a 404 image? for images that cannot be read by ASP.NET -


Using ASP.NET C # to host file studio / files. I allow users to upload images and I redirect them to the media page. The images are in a special path that are easily recognizable. When I redirect, I get 2 out of 2 errors I 1) The image does not exist (not generated) or 2) Can not open the file (imagemagic or anyone who writes the image).

How do I stop 404 or other errors when I receive thesis errors and 'processing' or the current unavailable placeholder image?

protected zero application_Error (object sender, EventArgs e) {var ex = Server.GetLastError (); Var exx = ex as HttpException; HttpContext ctx = HttpContext.Current; Var url = MyCode.CleanPath (ctx); If (MyCode.SomeRegexPattern.IsMatch (url)) {var code = ctx.Response.StatusCode; If (exx! = Null) ctx.Response.StatusCode = exx.GetHttpCode (); Otherwise if (ex.Message.IndexOf ("Can not access the file")! = -1) ctx.Response.StatusCode = 500; Ctx.Response.ContentType = "image / gif"; Server.Transfer ("path / to / processing.gif"); }}

Comments

Popular posts from this blog

asp.net - Change the driver in the connection string to a data source in VB.Net -

Getting started consuming web services in a Ruby on Rails 3 application -

objective c - iPhone and it's wireless area -