Click here to Skip to main content
15,889,200 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Custom Configuration section Pin
indian14311-Jul-11 6:57
indian14311-Jul-11 6:57 
GeneralRe: Custom Configuration section Pin
GenJerDan11-Jul-11 7:14
GenJerDan11-Jul-11 7:14 
AnswerRe: Custom Configuration section Pin
Shameel11-Jul-11 21:41
professionalShameel11-Jul-11 21:41 
Questionsms application Pin
shawn41411-Jul-11 0:17
shawn41411-Jul-11 0:17 
AnswerRe: sms application Pin
DaveAuld11-Jul-11 0:24
professionalDaveAuld11-Jul-11 0:24 
AnswerRe: sms application Pin
Shameel11-Jul-11 2:34
professionalShameel11-Jul-11 2:34 
Questionread file base64 and show on the image Pin
apadana_198910-Jul-11 20:14
apadana_198910-Jul-11 20:14 
AnswerRe: read file base64 and show on the image Pin
Joris Janssens11-Jul-11 7:59
professionalJoris Janssens11-Jul-11 7:59 
Use a generic handler to read the base64 encoded image , decode it and output it to the browser. Feel free to use Session or Request to pass parameters to the handler to determine which file to read.

If you use ASP.NET 4 you can use the very convenient MemoryStream.CopyTo()-method, in versions below you'll have to do the copying yourself.

In your webform you can use it like this: <asp:Image ImageUrl="Base64ImageHandler.ashx" runat="server" /> (using the HTML img-element works too ofcourse)

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

using System;
using System.Web;
using System.IO;

public class Base64ImageHandler : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "image/jpeg";
        string data64 = File.ReadAllText(@"e:\flotspe\www\images\5base64.txt");
        byte[] data = Convert.FromBase64String(data64);
        
        using (MemoryStream ms=new MemoryStream(data)) {
            ms.CopyTo(context.Response.OutputStream);
            //CopyStream(ms, context.Response.OutputStream); // for ASP.NET 3.5 or below
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }
    private static void CopyStream(Stream input, Stream output) {
        byte[] buffer = new byte[32768];
        while (true) {
            int read = input.Read(buffer, 0, buffer.Length);
            if (read <= 0)
                return;
            output.Write(buffer, 0, read);
        }
    } 
}

AnswerRe: read file base64 and show on the image Pin
Joris Janssens12-Jul-11 1:03
professionalJoris Janssens12-Jul-11 1:03 
Questiongridview can go last page index? Pin
buffering839-Jul-11 23:35
buffering839-Jul-11 23:35 
AnswerRe: gridview can go last page index? Pin
Viral Upadhyay10-Jul-11 17:56
Viral Upadhyay10-Jul-11 17:56 
Questioncreate html file on the server side Pin
apadana_19899-Jul-11 20:28
apadana_19899-Jul-11 20:28 
AnswerRe: create html file on the server side Pin
Shahriar Iqbal Chowdhury/Galib10-Jul-11 4:06
professionalShahriar Iqbal Chowdhury/Galib10-Jul-11 4:06 
AnswerRe: create html file on the server side Pin
Not Active10-Jul-11 5:42
mentorNot Active10-Jul-11 5:42 
QuestionASP.NET Base Pages Pin
Patrick Skelton8-Jul-11 23:09
Patrick Skelton8-Jul-11 23:09 
AnswerRe: ASP.NET Base Pages Pin
TweakBird8-Jul-11 23:21
TweakBird8-Jul-11 23:21 
GeneralRe: ASP.NET Base Pages Pin
Not Active9-Jul-11 3:28
mentorNot Active9-Jul-11 3:28 
GeneralRe: ASP.NET Base Pages Pin
TweakBird10-Jul-11 6:01
TweakBird10-Jul-11 6:01 
AnswerRe: ASP.NET Base Pages Pin
Not Active9-Jul-11 3:27
mentorNot Active9-Jul-11 3:27 
GeneralRe: ASP.NET Base Pages Pin
Patrick Skelton9-Jul-11 7:50
Patrick Skelton9-Jul-11 7:50 
GeneralRe: ASP.NET Base Pages Pin
Firo Atrum Ventus10-Jul-11 18:02
Firo Atrum Ventus10-Jul-11 18:02 
GeneralRe: ASP.NET Base Pages Pin
Patrick Skelton10-Jul-11 23:15
Patrick Skelton10-Jul-11 23:15 
QuestionFacebook connect Pin
benams8-Jul-11 15:50
benams8-Jul-11 15:50 
AnswerRe: Facebook connect Pin
Parwej Ahamad8-Jul-11 16:13
professionalParwej Ahamad8-Jul-11 16:13 
GeneralRe: Facebook connect Pin
benams8-Jul-11 16:23
benams8-Jul-11 16:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.