Hi All,
I am using grid with image column. When user's click image to opened up image(jpg,jpeg,bmp,gif) via a image and fax viewer (i.e by the operating system). i have try to open but it's open in IE any one please me.
Thanks
Anandh
Hi All,
I am using grid with image column. When user's click image to opened up image(jpg,jpeg,bmp,gif) via a image and fax viewer (i.e by the operating system). i have try to open but it's open in IE any one please me.
Thanks
Anandh
: the browser decides how image MIME types are handled, so a web page cannot directly launch the OS Image and Fax Viewer. The reliable workaround is to make the browser treat the file as a download (so the user gets an Open/Save dialog). If the user chooses Open, the OS will hand the file to the default image viewer.
Implement a server-side "download" endpoint that streams the image with a Content-Disposition: attachment header. Call that endpoint from your grid click (for example: DownloadImage.ashx?id=123). Important: validate the id, map it to a safe path, and never expose arbitrary file paths.
Example VB.NET IHttpHandler (minimal):
Imports System.IO
Imports System.Web
Public Class DownloadImage
Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim id As String = context.Request.QueryString("id")
Dim filePath As String = MapIdToPath(id) ' validate and map securely
If Not File.Exists(filePath) Then
context.Response.StatusCode = 404
Return
End If
Dim fileName As String = Path.GetFileName(filePath)
context.Response.Clear()
context.Response.ContentType = "application/octet-stream"
context.Response.AddHeader("Content-Disposition", "attachment; filename=""" & fileName & """")
context.Response.TransmitFile(filePath)
context.Response.End()
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class Notes and troubleshooting:
application/octet-stream or attachment to force a download; serving as image/jpeg will render inline.TransmitFile is preferable to WriteFile for performance.Content-Disposition (MDN) and the ASP.NET TransmitFile API (Microsoft).This approach avoids relying on right-click client changes (as mentioned) and works when grid right-click is disabled.
Jump to Post— catherine sea 15Try right-click a JPG file in Windows Explorer, click Open With->Choose default program, set a image or fax viewer you prefer to see if it works.
Try right-click a JPG file in Windows Explorer, click Open With->Choose default program, set a image or fax viewer you prefer to see if it works.
Thanks for your reply, In the grid right-click option is disabled. So we need the precessing for when user click the image to open via image and fax viewer.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.