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 6649739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:48:36+00:00 2026-05-26T00:48:36+00:00

recently i created a webpage, where in i have a img tag, whose source

  • 0

recently i created a webpage, where in i have a img tag, whose source is linked to another page, where i am resizing the image, whose name is being sent from the src from previous page in query string. but when i create the new object of bitmap, i gets the error, Parameter is not valid.

below is the code which holds image tag.

 <img src='/resize.aspx?file=PRO_06_11_Final-272.jpg&width=128&height=73' alt="Nothing" />

below is the code for the resize page where i am resizing image and sending the bitmap object through response

if (Request.QueryString["file"] != null)
        {

            int lnHeight = Convert.ToInt32(Request.QueryString["height"]);
            int lnWidth = Convert.ToInt32(Request.QueryString["width"]);
            string imgUrl = Request.QueryString["file"].ToString();
            Bitmap bmpOut = null;
            try
            {
                Bitmap loBMP;
                loBMP = new Bitmap(Server.MapPath(imgUrl)); //Parameter is not valid.. error is thrown here.
                System.Drawing.Imaging.ImageFormat loFormat = loBMP.RawFormat;
                decimal lnRatio;
                int lnNewWidth = 0;
                int lnNewHeight = 0;
                //-----If the image is smaller than a thumbnail just return it As it is----- 
                if ((loBMP.Width < lnWidth && loBMP.Height < lnHeight))
                {
                    lnNewWidth = loBMP.Width;
                    lnNewHeight = loBMP.Height;
                }
                if ((loBMP.Width > loBMP.Height))
                {
                    lnRatio = (decimal)lnHeight / loBMP.Height;
                    lnNewHeight = lnHeight;
                    decimal lnTemp = loBMP.Width * lnRatio;
                    lnNewWidth = (int)lnTemp;
                    if (lnNewWidth > 128)
                    {
                        lnNewWidth = 128;
                    }
                 }
                else
                {
                    lnRatio = (decimal)lnHeight / loBMP.Height;
                    lnNewHeight = lnHeight;
                    decimal lnTemp = loBMP.Width * lnRatio;
                    lnNewWidth = (int)lnTemp;
                    if (lnNewWidth < 75)
                    {
                        lnNewWidth = 75;
                    }
                }
                bmpOut = new Bitmap(lnNewWidth, lnNewHeight);
                Graphics g = Graphics.FromImage(bmpOut);
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight);
                Response.ContentType = "image/jpeg";
                bmpOut.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write("CreateThumbnail :" + ex.ToString());
            }
            finally
            {
            }
        }

the above code works fine in local Machine on FileSystem, but when i put the same code on dev server, the application starts throwing message..

can anyone tell me what could be the cause for this problem only on dev server.

  • 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-26T00:48:37+00:00Added an answer on May 26, 2026 at 12:48 am

    If you don’t specify a root folder for Server.MapPath it will add the location of the currently executing aspx file. You can read more at msdn

    If Path doesn't start with a slash, the MapPath method returns a path relative to the directory of the .asp file being processed
    

    As Hanlet mentioned you need to add an images root folder. So your code will become

    string imgRoot = "~/images/";
    try
    {
        ...
    
        loBMP = new Bitmap(Server.MapPath(imgRoot + imgUrl));
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently created a menu for a web page where buttons are DIV elements.
I have a webpage and I was recently asked to create the mobile version
Recently I created a script that accesses another script to run it. The only
I recently created a new template page, I put the obligatory <?php /* Template
I have recently created an EC2 account on Amazon Web Services. I have created
I recently created a ListView using ListAdapter and applied a static background image behind
I have recently created a Universal App in Xcode 4 to build my new
I have a static html web page for my website and recently was not
I recently created a project (open source) on Google projects hosting. I want to
I recently created a fb page for sharing my photography work. I'm new to

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.