Click here to Skip to main content
15,912,977 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: login page in asp.net Pin
Richard Deeming19-Jun-15 2:00
mveRichard Deeming19-Jun-15 2:00 
GeneralRe: login page in asp.net Pin
Mr Munesh Sharma19-Jun-15 1:12
professionalMr Munesh Sharma19-Jun-15 1:12 
GeneralRe: login page in asp.net Pin
Richard Deeming19-Jun-15 2:02
mveRichard Deeming19-Jun-15 2:02 
GeneralRe: login page in asp.net Pin
Richard Deeming19-Jun-15 2:06
mveRichard Deeming19-Jun-15 2:06 
Questionfind whole name list from word using textbox Pin
Member 1158609811-Jun-15 22:36
Member 1158609811-Jun-15 22:36 
QuestionRe: find whole name list from word using textbox Pin
ZurdoDev12-Jun-15 8:13
professionalZurdoDev12-Jun-15 8:13 
QuestionMessage Closed Pin
11-Jun-15 7:31
Stephen Holdorf11-Jun-15 7:31 
RantREPOST Pin
Richard Deeming11-Jun-15 7:52
mveRichard Deeming11-Jun-15 7:52 
QuestionUnchecked returned value causing unexpected states and conditions. Pin
Stephen Holdorf10-Jun-15 7:35
Stephen Holdorf10-Jun-15 7:35 
AnswerRe: Unchecked returned value causing unexpected states and conditions. Pin
Richard Deeming10-Jun-15 7:56
mveRichard Deeming10-Jun-15 7:56 
AnswerRe: Unchecked returned value causing unexpected states and conditions. Pin
Sascha Lefèvre10-Jun-15 15:01
professionalSascha Lefèvre10-Jun-15 15:01 
GeneralMessage Closed Pin
11-Jun-15 8:34
Stephen Holdorf11-Jun-15 8:34 
GeneralRe: Unchecked returned value causing unexpected states and conditions. Pin
Richard Deeming11-Jun-15 8:43
mveRichard Deeming11-Jun-15 8:43 
QuestionWeb.config file debug="true" setting Pin
Stephen Holdorf10-Jun-15 3:48
Stephen Holdorf10-Jun-15 3:48 
AnswerRe: Web.config file debug="true" setting Pin
Richard Deeming10-Jun-15 4:02
mveRichard Deeming10-Jun-15 4:02 
QuestionAllowing the attacker to access unathorized records finding. Pin
Stephen Holdorf8-Jun-15 7:00
Stephen Holdorf8-Jun-15 7:00 
AnswerMessage Closed Pin
8-Jun-15 8:52
Stephen Holdorf8-Jun-15 8:52 
GeneralRe: Allowing the attacker to access unathorized records finding. Pin
Stephen Holdorf8-Jun-15 10:02
Stephen Holdorf8-Jun-15 10:02 
QuestionChosing the best technology Pin
rcanales7-Jun-15 21:23
rcanales7-Jun-15 21:23 
AnswerRe: Chosing the best technology Pin
Afzaal Ahmad Zeeshan8-Jun-15 1:42
professionalAfzaal Ahmad Zeeshan8-Jun-15 1:42 
QuestionGet Image on HTML on the fly from ASP.NET ASPX source not working Pin
DavidMills026-Jun-15 4:28
DavidMills026-Jun-15 4:28 
I would like to be able to have on a plain HTML page and image that is dynamically created from a link to an ASP.NET page

HTML
<img src="http://www.domanin
name.co.uk/GetImage.aspx?filename=ImageName.png&width=200">


I have the following code in the GetImage.aspx page


VB
```

<script runat="server">
    Dim strServerPath, strFilename As String
    
    Private Sub Page_Load(sender As Object, e As System.EventArgs)
        Dim filename As String = Request.QueryString("filename")
        Dim width As Integer = Integer.Parse(Request.QueryString("width"))
        strServerPath = Server.MapPath("images\")
        strFilename = strServerPath & Request.QueryString("filename")
        
        Me.GenerateThumbnail(Server.MapPath(strFilename), width)
    End Sub

    Private Sub GenerateThumbnail(filename As String, width As Integer)
        Try
            Using orig As System.Drawing.Image = System.Drawing.Image.FromFile(filename)
                Me.GenerateThumbnail2(orig, New Size(width, CalculateHeight(orig, width)), GetFormat(filename))
            End Using
        Catch ex As Exception

        End Try
    End Sub

    Private Sub GenerateThumbnail2(orig As System.Drawing.Image, size As Size, format As ImageFormat)
        Try
            Using stream As New MemoryStream()
                Dim callback As New System.Drawing.Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback)
                Dim img As System.Drawing.Image = orig.GetThumbnailImage(size.Width, size.Height, callback, IntPtr.Zero)
                img.Save(stream, format)
                Response.ContentType = "image/" + format.ToString()
                Response.BinaryWrite(stream.ToArray())
                'img.Save(Response.OutputStream, ImageFormat.Jpeg)
                img.Dispose()
                Response.Flush()

            End Using
            
        Catch ex As Exception
            Try
                Dim img As System.Drawing.Image = Drawing.Image.FromFile(strFilename)
                img.Save(Response.OutputStream, ImageFormat.Jpeg)
                
            Catch
                Dim img As System.Drawing.Image = Drawing.Image.FromFile(strServerPath & "PaddySheepskinSlippers1.png")
                img.Save(Response.OutputStream, ImageFormat.Jpeg)
                
            End Try
        End Try
        
    End Sub

    Private Shared Function GetFormat(filename As String) As ImageFormat
        If filename.EndsWith("jpg") OrElse filename.EndsWith("jpeg") OrElse filename.EndsWith("tiff") Then
            Return ImageFormat.Jpeg
        End If

        Return ImageFormat.Png
    End Function

    Private Shared Function CalculateHeight(img As System.Drawing.Image, desiredWidth As Double) As Integer
        Dim power As Double = img.Width / desiredWidth
        Return CInt(img.Height / power)
    End Function

    Private Function ThumbnailCallback() As Boolean
        Return False
    End Function
</script>

```



But my HTML page does not display the image.

I would appreciate if someone could tell me what I have done wrong or omitted in the code. Thank you
AnswerRe: Get Image on HTML on the fly from ASP.NET ASPX source not working Pin
F-ES Sitecore6-Jun-15 14:41
professionalF-ES Sitecore6-Jun-15 14:41 
SuggestionRe: Get Image on HTML on the fly from ASP.NET ASPX source not working Pin
Richard Deeming7-Jun-15 21:58
mveRichard Deeming7-Jun-15 21:58 
SuggestionRe: Get Image on HTML on the fly from ASP.NET ASPX source not working Pin
Kornfeld Eliyahu Peter8-Jun-15 0:51
professionalKornfeld Eliyahu Peter8-Jun-15 0:51 
QuestionEval_Bind Pin
Member 111616255-Jun-15 20:08
Member 111616255-Jun-15 20:08 

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.