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

  • Home
  • SEARCH
  • 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 7038749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:42:24+00:00 2026-05-28T01:42:24+00:00

I am having an issue with my ASP.Net application when it runs in IIS6

  • 0

I am having an issue with my ASP.Net application when it runs in IIS6 (Windows Server 2003) but it runs flawlessly in IIS7 (Windows Server 2008R2). I am using an ASHX to resize images and then display the results in an ASP:Image control on another winform (DisplayImage.aspx). When I run the application in IIS7 it displays the image in the ASP:Image control perfectly but when I run it in IIS6 the image is not displayed. I do not receive any errors on the IIS6 box just the proverbial box with a red X. Here is my code:

Here is the code from Display image aspx WinForm:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Not IsPostBack Then
    ''Code to retrieve filename here
    With Image1
        .ImageUrl = "~/ImageHandler.ashx?imageName=" & filePath 
    End With
End If

End Sub

Here is the HTML/ASP.Net code from DisplayImage.aspx

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="DisplayImage.aspx.vb" Inherits="Mobile.DisplayImage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

    <head id="Head1" runat="server">
        <meta content="index,follow" name="robots" />
        <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
        <meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />

        <meta name="HandheldFriendly" content="true" />
        <meta name="viewport" content="width=device-width" />

        <link href="../css/style.css" rel="stylesheet" type="text/css" />

        <script src="../scripts/functions.js" type="text/javascript"></script>

        <title>CrimeNtel</title>
    </head>
    <body>
        <form id="theform" runat="server">
            <div id="topbar">
                <div id="leftnav">
                    <a href="Default.aspx"><img alt="home" src="../images/home.png" /></a><a id="goback" runat="server">Return</a>
                </div>
                <div>
                    Image Viewer
                </div>
            </div>
            <div>
                <fieldset>
                    <span>
                        <div id="titleHeader" runat="server" style="text-align:center">Linked Image</div>
                    </span>

                    <div style="text-align:center" style="text-align:center">
                        <asp:Image ID="Image1" runat="server" />
                    </div>
                </fieldset>
            </div>
        </form> 
    </body>
</html>

Here is the code behind from the ImageHandler.ashx:

Imports System.Web
Imports System.Web.Services
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports System.Web.Mobile
Imports System.IO

Public Class ImageHandler
    Implements System.Web.IHttpHandler


    Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        Dim fileName As String = HttpContext.Current.Request("imagename")
        Dim screenHeight As Integer = 300
        Dim screenWidth As Integer  = 300
        Dim fileExtension As String = Path.GetExtension(fileName).Replace(".", "").ToUpper

        Select Case fileExtension.ToUpper
            Case "JPG"
                context.Response.ContentType = "image/jpg"
            Case "PNG"
                context.Response.ContentType = "image/png"
            Case "BMP"
                context.Response.ContentType = "image/bmp"
            Case "GIF"
                context.Response.ContentType = "image/GIF"
            Case Else
                context.Response.ContentType = "image/jpg"
        End Select

    ''Loads Virtual Directory  from Web Config File
       ''Note Virtual Directory is located in the Root of the Default Web Site
        Dim _virtualDirectory As String = ConfigurationManager.AppSettings("VirtualDirectory")

        Try
        Dim bmp As Bitmap = New Bitmap((_virtualDirectory & fileName.Trim)

                Dim img As System.Drawing.Image = FixedSize(bmp, screenWidth, screenHeight)
                img.Save(_virtualDirectory & "/Thumbs/displayedImage." & fileExtension)
                img.Dispose()
                context.Response.WriteFile(_virtualDirectory & "/Thumbs/displayedImage." & fileExtension)

        Catch ex As Exception
            'context.Response.Write("<script>alert('" & ex.Message & "');</script>")
        End Try
    End Sub

    Private Shared Function FixedSize(imgPhoto As Image, Width As Integer, Height As Integer) As Image
        ''Found code at 
        ''http://www.codeproject.com/KB/GDI-plus/imageresize.aspx

        Dim sourceWidth As Integer = imgPhoto.Width
        Dim sourceHeight As Integer = imgPhoto.Height
        Dim sourceX As Integer = 0
        Dim sourceY As Integer = 0
        Dim destX As Integer = 0
        Dim destY As Integer = 0

        Dim nPercent As Single = 0
        Dim nPercentW As Single = 0
        Dim nPercentH As Single = 0

        nPercentW = (CSng(Width) / CSng(sourceWidth))
        nPercentH = (CSng(Height) / CSng(sourceHeight))

        If nPercentH < nPercentW Then
            nPercent = nPercentH
            destX = System.Convert.ToInt16((Width - (sourceWidth * nPercent)) / 2)
        Else
            nPercent = nPercentW
            destY = System.Convert.ToInt16((Height - (sourceHeight * nPercent)) / 2)
        End If

        Dim destWidth As Integer = CInt(Math.Truncate(sourceWidth * nPercent))
        Dim destHeight As Integer = CInt(Math.Truncate(sourceHeight * nPercent))

        Dim bmPhoto As New Bitmap(Width, Height, PixelFormat.Format24bppRgb)
        bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution)

        Dim grPhoto As Graphics = Graphics.FromImage(bmPhoto)
        grPhoto.Clear(System.Drawing.ColorTranslator.FromHtml("#C5CCD4"))  'Color.DarkGray) ' Color.White)
        grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic

        grPhoto.DrawImage(imgPhoto, New Rectangle(destX, destY, destWidth, destHeight), New Rectangle(sourceX, sourceY, sourceWidth, sourceHeight), GraphicsUnit.Pixel)

        grPhoto.Dispose()
        Return bmPhoto
    End Function

    ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property
End Class

Solution

What was the issue is that the website was running under the correct creditials but I had to add the following line of code to my Web Config File so that my app would impersonate the user who had access to the files:

<system.web>
    <!--This will allow website to run under a different account than that of ASP.Net
      <identity impersonate="true" userName="DomainName\UserName" password="p@5sW0Rd"/>
</system.web>
  • 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-05-28T01:42:24+00:00Added an answer on May 28, 2026 at 1:42 am

    I think it is a permission problem. You need to grant network services access to the folder containing the image.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue with my ASP.Net MVC application, I'm using MVC 3 with
I'm having trouble deploying an ASP.Net application using Sql Server CE 4.0. I get
I am having an issue with a website developed using ASP.Net/C# sometimes taking all
We're having a weird issue with offering a file on our ASP.NET server. If
I am having a weird issue in MVC. I am using ASP.Net MVC, I
I am using SignalR in an ASP.Net Web Application project and am having issues.
I'm working on my first application using ASP.Net with web services and I'm having
I am having log4net permission issue from ASP.Net 4.0 web application to write to
I am having an issue on the controller side using ASP.Net MVC 3 trying
I am having an issue with caching the home page of my Asp.Net Mvc

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.