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

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -