473,508 Members | 2,361 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Set file name returned from ASP.NET page by URL

Hi!
I have an .aspx page which returns an image. This page takes some GET
parameters, so URL looks like this:
http://localhost/page.aspx?id=1234
Now, when the user click this link, I want that his browser would receive
picture with some good looking name, like image1.jpg.
How to do this within ASP.NET code ?..

--
Paweł
www.DATAX.pl
Nov 18 '05 #1
4 1421
Write an HTTPHandler. Using the Handler, you can make a request for an image
file and get back whatever the handler returns. For example,

http://localhost/image1.jpg?id=1234

would return an image named "image1.jpg" - which could be anything you
generate via your Handler.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"pawel" <pa************@interia.pl> wrote in message
news:#1**************@TK2MSFTNGP10.phx.gbl...
Hi!
I have an .aspx page which returns an image. This page takes some GET
parameters, so URL looks like this:
http://localhost/page.aspx?id=1234
Now, when the user click this link, I want that his browser would receive
picture with some good looking name, like image1.jpg.
How to do this within ASP.NET code ?..

--
Paweł
www.DATAX.pl

Nov 18 '05 #2
Thanks for the answer.
Can you shortly tell me what exactly is that HTTPHandler ?.. I cant find
such topic in MSDN.
Paul

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Write an HTTPHandler. Using the Handler, you can make a request for an image file and get back whatever the handler returns. For example,

http://localhost/image1.jpg?id=1234

would return an image named "image1.jpg" - which could be anything you
generate via your Handler.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"pawel" <pa************@interia.pl> wrote in message
news:#1**************@TK2MSFTNGP10.phx.gbl...
Hi!
I have an .aspx page which returns an image. This page takes some GET
parameters, so URL looks like this:
http://localhost/page.aspx?id=1234
Now, when the user click this link, I want that his browser would receive picture with some good looking name, like image1.jpg.
How to do this within ASP.NET code ?..

--
Paweł
www.DATAX.pl


Nov 18 '05 #3
You might try something like this:

Response.Clear();
Response.AddHeader("Content-Disposition","inline;filename=image1.jpg");
Response.WriteFile("myfile.jpg");

Here's more info:
http://msdn.microsoft.com/library/de...efiletopic.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"pawel" <pa************@interia.pl> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi!
I have an .aspx page which returns an image. This page takes some GET
parameters, so URL looks like this:
http://localhost/page.aspx?id=1234
Now, when the user click this link, I want that his browser would receive
picture with some good looking name, like image1.jpg.
How to do this within ASP.NET code ?..

--
Paweł
www.DATAX.pl

Nov 18 '05 #4
Sure. An HttpHandler is a class that handles HTTP requests. In ASP.Net a
Page class, for example, is the default HttpHandler for files with a .aspx
extension. You can map different file extensions to different HttpHandlers
in ASP.Net. What happens is, when the web server receives a request for a
file, it looks in its configuration to find out whether a special
HttpHandler has been designated for that file extension. ASP.Net provides
the HttpHandler class to extend the functionality of ASP.net to be able to
handle requests for other file types (extensions). In IIS, you make ASP.Net
the HttpHandler for the type of file that you desire, and use the web.config
file for your web to identify what DLL (Class Library) is used to handle
specific file extensions.

The HttpHandler is a clsss that handles the request. It has access to the
same HttpContext (Request, Response, Cookies, Session, Application, Server,
etc) that the Page class does.

For more detailed information, see:

http://msdn.microsoft.com/library/de...tphandlers.asp

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"pawel" <pa************@interia.pl> wrote in message
news:uL**************@TK2MSFTNGP12.phx.gbl...
Thanks for the answer.
Can you shortly tell me what exactly is that HTTPHandler ?.. I cant find
such topic in MSDN.
Paul

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Write an HTTPHandler. Using the Handler, you can make a request for an

image
file and get back whatever the handler returns. For example,

http://localhost/image1.jpg?id=1234

would return an image named "image1.jpg" - which could be anything you
generate via your Handler.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"pawel" <pa************@interia.pl> wrote in message
news:#1**************@TK2MSFTNGP10.phx.gbl...
Hi!
I have an .aspx page which returns an image. This page takes some GET
parameters, so URL looks like this:
http://localhost/page.aspx?id=1234
Now, when the user click this link, I want that his browser would receive picture with some good looking name, like image1.jpg.
How to do this within ASP.NET code ?..

--
Paweł
www.DATAX.pl



Nov 18 '05 #5

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

Similar topics

1
4260
by: CES | last post by:
All, I'm trying to figure out how I would execute code that would be shared over a number of wwwroot folders. Basically it would be the equivalent of an .inc file only instead of residing...
9
3715
by: Rich | last post by:
Hi, I have a bunch of Excel reports that I would like to display on my company's intranet. The reports contain priviledged information, however. My plan was to have a page with a dropdown box...
10
1848
by: James_101 | last post by:
My training piece is in Authorware. The user logs in with last name and a four-digit number. Authorware sends this user identifier to an asp page called db_read.asp. This file sends a SQL SELECT...
11
3000
by: Andrew Thompson | last post by:
I have written a few scripts to parse the URL arguments and either list them or allow access to the value of any parameter by name. <http://www.physci.org/test/003url/index.html>...
0
3910
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
3
1763
by: CES | last post by:
All, I'm trying to figure out how I would execute code that would be shared over a number of wwwroot folders. Basically it would be the equivalent of an .inc file only instead of
5
12270
by: Neil Rossi | last post by:
I have an issue with a particular ASP page on two web servers. Let's call these servers Dev1 and Beta1. Both Servers are running IIS 5, Windows 2000 SP4 with "almost" all of the latest patches. ...
1
6441
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
2
3168
by: Michael D. Ober | last post by:
When I single step through the code below, it sends back the PDF file that is retrieved in the line fm.GetAccountPDF(...). When I run without single stepping, I get the master page for this page. ...
0
1450
by: =?Utf-8?B?QnJ5YW4=?= | last post by:
Hello group. I've migrated from Win 2003 server to Win 2008 server. I've been banging my head agaist a wall for several days now trying to figure this out. I have the following script that will...
0
7115
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
7321
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,...
1
7036
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
7489
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...
0
5624
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.