Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8332767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:49:02+00:00 2026-06-09T02:49:02+00:00

I have a webpage that contains an aspImage control When I retrive an image

  • 0

I have a webpage that contains an aspImage control
When I retrive an image from database via an image handler I can show that image in the aspImage control ! BUT . . . the problem is when I right click on the image and click “save picture as” I get this error message : The file type being saved or retrieved has been blocked !
I wonder if this is an IE issue or something is wrong with my code ?! any help ?!

Here is my image handler code :

    <%@ WebHandler Language="C#" Class="Handler" %>

using System;
using System.Configuration;
using System.Data.SqlClient;
using System.Web;

public class Handler : IHttpHandler, System.Web.SessionState.IRequiresSessionState 
{

    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString);
    public void ProcessRequest(HttpContext context)
    {
        string TableName=context.Session["TableToQuery"].ToString();
        string ID=context.Session["ID"].ToString();

        SqlCommand comm = new SqlCommand("SELECT * FROM "+ TableName +" WHERE ID=" + ID, conn);

        conn.Open();
        SqlDataReader dr = comm.ExecuteReader();
        dr.Read();
        context.Response.BinaryWrite((byte[])dr["Image"]);
        conn.Close();
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}

And here is the datalist in wich I show my image :

<asp:DataList ID="DL" runat="server" Width="100%" Height="100%" RepeatColumns="1"
                            RepeatDirection="Vertical">
                            <ItemTemplate>
                                <table style="height: 100%; width: 100%">
                                    <tr style="width: 100%; height: 350px">
                                        <td valign="middle">
                                            <asp:Image ID="IMage" runat="server" ImageUrl='<%# "Handler.ashx?ID=" + Eval("ID") %>' />
                                        </td>
                                    </tr>
                                    <tr style="width: 100%; height: 250px">
                                        <td valign="top">
                                            <asp:TextBox ID="txtDecoded" runat="server" TextMode="MultiLine" Width="316px"
                                                Height="200px" Text='<%#Eval("DecodedString")%>'></asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                        </asp:DataList>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T02:49:03+00:00Added an answer on June 9, 2026 at 2:49 am

    You are not sending any headers declaring the MIME type of the contents, just a context.Response.BinaryWrite

    At the very least you should add something like this before the BinaryWrite

    context.Response.ContentType = "image/jpeg";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webpage that contains a form, and i need to refresh the
I have a asp.net webpage that contain a custom login control like this: <div
I have a webpage that retrieves data (via ajax/php) and shows it in an
I have a header on my webpage that contains the some javascript for some
I have an input field on a webpage that contains a credit-card number. What
I have an ASP.NET 4 webpage that contains an update panel which just allows
I have an asp.net webpage that only contains a textbox and a button. The
We have a webpage that contains three grids full of data. The grids are
I have a NSString that contains the html code of a webpage. Now, how
I have a webpage that contains ASP.NET panels and JavaScript that gets all of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.