Image control's URL issue

Last post 01-24-2008 2:15 AM by jadoon88. 19 replies.

Sort Posts:

  • Image control's URL issue

    01-14-2008, 7:04 AM
    • Loading...
    • jadoon88
    • Joined on 12-09-2007, 4:41 AM
    • Pakistan
    • Posts 70

    I am new in .net and have some confusions and problems

    I have an image file saved at C:\memberimages\image1.jpg and I have create an ASP.net image control named memberImage and I want it to display this image, how can I?

    I have tried memberImage.ImageUrl="C:\\memberimages\\image1.jpg"; but it is not working. I don't want to save images to Application folder.

    I want to ask 2 things

    1)  How can I display that image in memberImage image control?

    2)  If I want to display image from a URL e.g www.abc.com/image.jpg then what will be the string literal for memberImage.ImageUrl?

    Note: I am using C#

    Umair Khan Jadoon
    Blog: www.technobuddy.net
  • Re: Image control's URL issue

    01-14-2008, 7:23 AM
    • Loading...
    • Eliyahu
    • Joined on 12-13-2005, 8:41 AM
    • Posts 52
    Your question ia about web programming rather than ..net.
     
    1) You need to specify a virtual path to the image, starting from the root for your web application.
     
    2) http://www.abc.com/image.jpg should do.

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net
     
     
    <jadoon88> wrote in message news:2108021@forums.asp.net...

    I am new in .net and have some confusions and problems

    I have an image file saved at C:\memberimages\image1.jpg and I have create an ASP.net image control named memberImage and I want it to display this image, how can I?

    I have tried memberImage.ImageUrl="C:\\memberimages\\image1.jpg"; but it is not working. I don't want to save images to Application folder.

    I want to ask 2 things

    1)  How can I display that image in memberImage image control?

    2)  If I want to display image from a URL e.g www.abc.com/image.jpg then what will be the string literal for memberImage.ImageUrl?

    Note: I am using C#


    Umair Khan Jadoon
    Blog: www.technobuddy.net

    http://forums.asp.net/p/1205203/2108021.aspx#2108021

    Eliyahu Goldin,
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net
  • Re: Image control's URL issue

    01-14-2008, 8:27 AM
    • Loading...
    • jadoon88
    • Joined on 12-09-2007, 4:41 AM
    • Pakistan
    • Posts 70

    Thankyou Sir, my 2nd issue is resolved.

    Can you please tell me in detail how can I specify a virtual path? I will be very thankful of you

    Umair Khan Jadoon
    Blog: www.technobuddy.net
  • Re: Image control's URL issue

    01-14-2008, 8:44 AM
    • Loading...
    • Eliyahu
    • Joined on 12-13-2005, 8:41 AM
    • Posts 52
    If you web site or project includes a folder called Images, and you store your images there, then the virtual path will be Images/abc.gif

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net
     
     
    <jadoon88> wrote in message news:2108176@forums.asp.net...

    Thankyou Sir, my 2nd issue is resolved.

    Can you please tell me in detail how can I specify a virtual path? I will be very thankful of you


    Umair Khan Jadoon
    Blog: www.technobuddy.net

    http://forums.asp.net/p/1205203/2108176.aspx#2108176

    Eliyahu Goldin,
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net
  • Re: Image control's URL issue

    01-16-2008, 8:41 AM
    • Loading...
    • jadoon88
    • Joined on 12-09-2007, 4:41 AM
    • Pakistan
    • Posts 70

    Eliyahu:
    If you web site or project includes a folder called Images, and you store your images there, then the virtual path will be Images/abc.gif

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net
     
     
    <jadoon88> wrote in message news:2108176@forums.asp.net...

    Thankyou Sir, my 2nd issue is resolved.

    Can you please tell me in detail how can I specify a virtual path? I will be very thankful of you


    Umair Khan Jadoon
    Blog: www.technobuddy.net

    http://forums.asp.net/p/1205203/2108176.aspx#2108176

    Thanx again, it works but now problem is when I try to save/upload a file using upload asp.net control I get an error that says permission denied to save file to that directory. :S How can I resolve this?

    Umair Khan Jadoon
    Blog: www.technobuddy.net
  • Re: Image control's URL issue

    01-17-2008, 7:25 AM
    Answer

    jadoon88:
    Thanx again, it works but now problem is when I try to save/upload a file using upload asp.net control I get an error that says permission denied to save file to that directory. :S How can I resolve this?

    Hi jadoon88,

    Base on my experience, you can try to use the following solution to solve your problem: 

    SOLUTION:

    To grant ASP.NET or other needed account write access to a folder, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the needed account, and check the boxes for the desired access.

    REFERENCES:

    NTFS File permissions:
    http://technet2.microsoft.com/WindowsServer/en/library/f4aadfb4-1af4-4e27-9ff0-3a650cd476dd1033.mspx?mfr=true

    ASP.NET Impersonation:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsent7/html/vxconimpersonation.asp

     

     

    And here is the original link:

    http://www.powupload.com/Access-to-the-path-is-denied.aspx

     

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Let me know if I have misunderstood what you mean. Thanks.

    Hope it helps,

    Hong Gang 

    Sincerely,
    Ocean
    Microsoft Online Community Support
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
  • Re: Image control's URL issue

    01-17-2008, 8:53 AM
    • Loading...
    • jadoon88
    • Joined on 12-09-2007, 4:41 AM
    • Pakistan
    • Posts 70

    Hong-Gang Chen - MSFT:

    SOLUTION:

    To grant ASP.NET or other needed account write access to a folder, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the needed account, and check the boxes for the desired access.

     



    Can't find security tab in Windows XP Professional :S how can I do this :'(
    Umair Khan Jadoon
    Blog: www.technobuddy.net
  • Re: Image control's URL issue

    01-17-2008, 9:20 AM
    Answer
    • Loading...
    • fimine
    • Joined on 01-17-2008, 2:01 PM
    • Montreal QC Canada
    • Posts 334

    1. Open Windows Explorer;

    2. When the C:\ folder opens, click on the Tools menu and then select Folder Options.

    3. Click on the View tab.

    4. Under Advanced Settings scroll down to the end and uncheck Use simple file sharing (Recommended).

    5. Press the Apply button and then the OK button.
    You will now be able to see the Security tab in a folder or file's properties

    Alexei Fimine
    _____________
    Don't forget to mark this post as "Answer" if it indeed answered.
  • Re: Image control's URL issue

    01-17-2008, 10:21 AM
    • Loading...
    • jadoon88
    • Joined on 12-09-2007, 4:41 AM
    • Pakistan
    • Posts 70

    fimine:

    1. Open Windows Explorer;

    2. When the C:\ folder opens, click on the Tools menu and then select Folder Options.

    3. Click on the View tab.

    4. Under Advanced Settings scroll down to the end and uncheck Use simple file sharing (Recommended).

    5. Press the Apply button and then the OK button.
    You will now be able to see the Security tab in a folder or file's properties

     


    Thankyou very much! Now problem is I have allowed full access (for testing purposes) and still get this error

    Groups or user names Iisted here are

    Administrators
    SYSTEM
    Umair Khan Jadoon
    (My name)

    there is no ASP.NET user name or group name listed here. I have tried finding the users by clicking Advanced>Advanced>Find Now  and still there's no ASP.NET user name or group found. Please help me its driving me crazy. I am using Visual Web Developer 2005 Professional and IIS 5 on Windows XP Professional
    Umair Khan Jadoon
    Blog: www.technobuddy.net
  • Re: Image control's URL issue

    01-17-2008, 11:26 AM
    • Loading...
    • fimine
    • Joined on 01-17-2008, 2:01 PM
    • Montreal QC Canada
    • Posts 334

     I am currently on a Domain controlled machine so it works a little differently. But try adding these to the list:

    YOURCOMPUTERNAME\ASPNET

    or just add "Everyone"  - a big security hole though.

    Also, don't use folders outside your root ASP.NET application folder - make all your temps as subfolders. This way you can simply run Permissions Wizard from your IIS. Plus, if you are publishing your website from VS2005 be aware of the fact that it erases and recreates everything on the "remote" location - permissions as well.

     

     

    Alexei Fimine
    _____________
    Don't forget to mark this post as "Answer" if it indeed answered.
  • Re: Image control's URL issue

    01-17-2008, 12:53 PM
    • Loading...
    • jadoon88
    • Joined on 12-09-2007, 4:41 AM
    • Pakistan
    • Posts 70

    fimine:

     I am currently on a Domain controlled machine so it works a little differently. But try adding these to the list:

    YOURCOMPUTERNAME\ASPNET

    or just add "Everyone"  - a big security hole though.

    Also, don't use folders outside your root ASP.NET application folder - make all your temps as subfolders. This way you can simply run Permissions Wizard from your IIS. Plus, if you are publishing your website from VS2005 be aware of the fact that it erases and recreates everything on the "remote" location - permissions as well.

     

     



    adding ComputerName\ASPNET didnt worked, I wznt able to add it. and adding "Everyone" still gives that error

    ...in properties of folder, under security tab, after clicking advanced>advanced>find now I can see the following groups and usernames listed there...can't find ASPNET :S ...I don't knwo whats hapening

    Umair Khan Jadoon
    Blog: www.technobuddy.net
  • Re: Image control's URL issue

    01-17-2008, 1:00 PM
    • Loading...
    • fimine
    • Joined on 01-17-2008, 2:01 PM
    • Montreal QC Canada
    • Posts 334

    then add IUSR_COMPUTERNAME

    if that doesn't help add NETWORK SERVICE.

     

     

    Alexei Fimine
    _____________
    Don't forget to mark this post as "Answer" if it indeed answered.
  • Re: Image control's URL issue

    01-17-2008, 1:06 PM
    • Loading...
    • fimine
    • Joined on 01-17-2008, 2:01 PM
    • Montreal QC Canada
    • Posts 334

    Actually, what OS are you running? How do you add the names?

    DON'T CLICK ADVANCED!!! 

    I do it the following way in WinXP SP2:

    1.  Right Click on the folder from Windows Explorer

    2.  Go to Security tab

    3.  Click Add

    4.  Click Locations...

    5. Choose my computer at the very top

    6.  Back at the select users and groups window to the left of the "Check names" button type "ASPNET" and press that button;

    7. The name should get your computer name attached at the left and get underlingned.

    8. Press ok.

    9. Follow the obvious from there.  

    Alexei Fimine
    _____________
    Don't forget to mark this post as "Answer" if it indeed answered.
  • Re: Image control's URL issue

    01-17-2008, 1:12 PM
    • Loading...
    • jadoon88
    • Joined on 12-09-2007, 4:41 AM
    • Pakistan
    • Posts 70

    still noo :'( I have added "Everyone" too

    Umair Khan Jadoon
    Blog: www.technobuddy.net
  • Re: Image control's URL issue

    01-17-2008, 1:14 PM
    • Loading...
    • fimine
    • Joined on 01-17-2008, 2:01 PM
    • Montreal QC Canada
    • Posts