473,396 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Show photo on ASP

I have an .NET ASP web application to show a photo depending on the person
selected. I used the url tag pointing to a file local to the server. All
works fine when running from the IDE. Problem: when I deploy it, I got a
permission error when creating the file. Question: where do I specify the
permission.
I am pretty new with web app, so any suggestion to alternate method is
welcome also.

Thanks.
Oct 4 '07 #1
6 2324
Phil,

This is most likely because on the server, ASP.NET is running under the
ASPNET local account, which doesn't have rights to the directory that you
specified. You have to either change the account that your application runs
under in the web.config file, or grant the ASPNET account permissions to
that directory.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Phil H" <ph*******@hotmail.comwrote in message
news:uZ**************@TK2MSFTNGP02.phx.gbl...
>I have an .NET ASP web application to show a photo depending on the person
selected. I used the url tag pointing to a file local to the server. All
works fine when running from the IDE. Problem: when I deploy it, I got a
permission error when creating the file. Question: where do I specify the
permission.
I am pretty new with web app, so any suggestion to alternate method is
welcome also.

Thanks.
Oct 4 '07 #2
I got a permission error when creating the file

Can you clarify; *showing* a photo sounds like a read operation, not a
write; are you writing the file into the local web? Generally, a
better option would be to simply stream it from source, perhaps using
a bespoke handler. You could also use virtual paths to bring the image
into the web itself.

Marc

Oct 4 '07 #3
I am reading the image from a database and writing into a file, No problem
there. I just cannot get the ImageURL to point to the right folder.

How do you stream the file into the web itself ? Where can I find out how ?

Thanks
"Marc Gravell" <ma**********@gmail.comwrote in message
news:11**********************@22g2000hsm.googlegro ups.com...
>I got a permission error when creating the file

Can you clarify; *showing* a photo sounds like a read operation, not a
write; are you writing the file into the local web? Generally, a
better option would be to simply stream it from source, perhaps using
a bespoke handler. You could also use virtual paths to bring the image
into the web itself.

Marc

Oct 4 '07 #4
I am reading the image from a database and writing into a file, No problem
there. I just cannot get the ImageURL to point to the right folder.

How do you stream the file into the web itself ? Where can I find out how ?
If I understand correctly, you simply don't need to write a file. What
I would do is in my page html (from aspx) page, refer to an image
(that doesn't exist) [see later], and then use a handler (e.g. ashx)
to serve the image. A handler is broadly just a fancy name for a class
that responds to requests, often much simpler than a full-blown aspx.
All it needs to do is:
* set the content-type so that the browser knows if it an image (and
what type)
* write the raw image to the response-stream

The latter is identical to working with a FileStream. The "handler"
step can be done in 2 ways; you can add a handler via the IDE and get
an .ashx file (with a query-string such as my.ashx?id=12345);
alternatively you can do the same without the actual ashx file, by
editing the httpHandlers section of web.config (you can then make the
URL look tidier, such as 12345.gif). Either way, the first thing your
handler has to do is to parse the URL to find which image to serve,
and fetch the binary.

A similar example: http://weblogs.asp.net/cazzu/archive.../27/25568.aspx
A good overview of handlers: http://msdn2.microsoft.com/en-us/library/ms972953.aspx

Marc

Oct 4 '07 #5
Thanks Marc.
It is a little over my head now. Let me see if if I can use the example and
learn somthing. Thanks for taking the time.

Phil
"Marc Gravell" <ma**********@gmail.comwrote in message
news:11**********************@r29g2000hsg.googlegr oups.com...
>I am reading the image from a database and writing into a file, No
problem
there. I just cannot get the ImageURL to point to the right folder.

How do you stream the file into the web itself ? Where can I find out how
?

If I understand correctly, you simply don't need to write a file. What
I would do is in my page html (from aspx) page, refer to an image
(that doesn't exist) [see later], and then use a handler (e.g. ashx)
to serve the image. A handler is broadly just a fancy name for a class
that responds to requests, often much simpler than a full-blown aspx.
All it needs to do is:
* set the content-type so that the browser knows if it an image (and
what type)
* write the raw image to the response-stream

The latter is identical to working with a FileStream. The "handler"
step can be done in 2 ways; you can add a handler via the IDE and get
an .ashx file (with a query-string such as my.ashx?id=12345);
alternatively you can do the same without the actual ashx file, by
editing the httpHandlers section of web.config (you can then make the
URL look tidier, such as 12345.gif). Either way, the first thing your
handler has to do is to parse the URL to find which image to serve,
and fetch the binary.

A similar example:
http://weblogs.asp.net/cazzu/archive.../27/25568.aspx
A good overview of handlers:
http://msdn2.microsoft.com/en-us/library/ms972953.aspx

Marc

Oct 5 '07 #6
Minor aside; the "read" steps would be tidier as follows:

while ((size = r.GetBytes(1, idx, buffer, 0, ChunkSize)) 0)
{
context.Response.BinaryWrite(buffer, 0, size);
idx += size;
}
(and remove the "last bytes" stuff)
This deals with a few edge-conditions more gracefully...

Oct 5 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Rudy | last post by:
Hello All! After working in the television industry, moving to a developing career has been interesting to say the least. 3 years of developing with books, and the help of you fine folks on this...
5
by: Sukhanov Volodya | last post by:
Hello, all! Does anybody knows, how I can show an image field SQL Server using VB. NET ? I have an database, which has an table with an field which has type 'image' (the type of field) I want...
0
by: Nathan Sokalski | last post by:
I have a very simple FormView control, but when I view the page it does not show the Paging controls, although it does show the data. Here is my code: <%@ Page Language="vb"...
7
subashini Thiyagarajan
by: subashini Thiyagarajan | last post by:
Hi friends, How do i include photo gallery in my swf file.i wanted to allocate small space for photo gallery in the same place if i press next or like a slide show i want to make all photo's ...
1
by: Oelie | last post by:
Hello, I'm trying to make a photo slide show in VB6. I'm trying to get the right size for my pictures, they have to fill up the screen entirely. It works with the first picture. But when a picture...
6
by: Méta-MCI \(MVP\) | last post by:
Hi! This code: import Image img = Image.open(r"D:\ParisNude.jpg") img.show() Don't run on my Vista computer. I have a solution:
1
by: cumupkid | last post by:
II am trying to create a form that will allow me to upload photos to a folder in the site root directory and add the information to the mysql db at the same time. I have created two forms, one...
1
oranoos3000
by: oranoos3000 | last post by:
hi i make a shopping online that in home page i show my product picture's to user (information product's such as address location of picture and name and the other properties is kept in database my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.