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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:43:20+00:00 2026-05-22T00:43:20+00:00

I have an image stored on server at location: C:\inetpub\wwwroot\imageupload\images in my code i

  • 0

I have an image stored on server at location:

C:\inetpub\wwwroot\imageupload\images

in my code i want to use an image from folder images so i am trying as follows:

Server.MapPath("/images/sample1.jpg")

But i am getting the error as:
enter image description here

Please help me to solve the error

As on several answer asking to post the code,it is as follows

.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<%@ Register Assembly="CS.Web.UI.CropImage" Namespace="CS.Web.UI" TagPrefix="cs" %>

<!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 runat="server">
    <title>Untitled Page</title>
</head>
<body>
 <cs:CropImage ID="wci1" runat="server" />
    </body>
</html>

.aspx.cs

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        wci1.Crop(Server.MapPath("/imageupload/images/sample1.jpg"));

        /*
         this part is just to show the image after its been cropped and saved! so focus on just the code above.
         */
        Image img = new Image();
        img.ImageUrl = "images/sample1.jpg?rnd=" + (new Random()).Next();  // added random for caching issue.
        this.Controls.Add(img);
    }
}

Crop method is from a .dll file i have used from http://imagecropping.codeplex.com/

  • 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-22T00:43:20+00:00Added an answer on May 22, 2026 at 12:43 am

    There error is in the CSA.Web.UI.CropImage.Crop method, as described by the stack trace.

    Server.MapPath, to my knowledge, will not return a null string (it’ll throw an exception if it can’t map – but not a NullReferenceException).

    I’d suggest you look into the method I mention and possibly post the relevant code, too.

    EDIT:

    So, I had a quick look at the Crop code from the CodePlex project you mention and found the following lines (formatting mine):

    private string ImagePath { get { return ViewState["ImageUrl"].ToString(); } }
    
    drawing.Image image = drawing.Image.FromStream(
        new MemoryStream(
            System.IO.File.ReadAllBytes(
                HttpContext.Current.Server.MapPath(this.ImagePath)
            )
        )
    );
    
    cropedImage.Save(path);
    

    Now, it seems to me that:

    • Argument Path is not null*
    • Argument ImageUrl is null**

    *Though it might be ‘incorrect’ it isn’t the problem right now.

    **Meaning the call ToString is the breaking factor in this code.

    Basically, the control doesn’t have an image set to crop and this is evident in your own code:

    //currently no ImageUrl set...
    <cs:CropImage ID="wci1" runat="server" />
    
    //your'e trying to crop here without an ImageUrl...
    wci1.Crop(Server.MapPath("/imageupload/images/sample1.jpg"));   
    

    The fix is to specify an image via ImageUrl, AFAIK, however I can’t see how to do so.

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

Sidebar

Related Questions

I have an image uploaded to a server with location like : opt/glassfish/domains/domain1/applications/j2ee-modules/SmartbadgePortal/images/2badge.jpg I
I have a image file stored at a remote server (i.e http://example.com/images).The images in
I have stored images from the net like this Documents/imagecache/domain1/original/path/inURI/foo.png Documents/imagecache/domain2/original/path/inURI/bar.png Documents/imagecache/... Documents/imagecache/... Now
I'm currently writing some code which will download images from my web server for
I have currently got imagepaths stored within the database and image files stored in
I have several images stored in content://media/external/images/media. I would like to display by using
I have an application with images stored in multiple categories, currently being stored by
I have a service that converts images stored on a website to byte array
I can't seem to get the images I have stored in isolated storage to
Currently we have thousands of Microsoft Word files, Excel files, PDF's, images etc stored

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.