Microsoft Designing ASP.NET Applications (0-7356-1348-6) for PC Logo
Posted on Aug 17, 2009
Answered by a Fixya Expert

Trustworthy Expert Solutions

At Fixya.com, our trusted experts are meticulously vetted and possess extensive experience in their respective fields. Backed by a community of knowledgeable professionals, our platform ensures that the solutions provided are thoroughly researched and validated.

View Our Top Experts

Donwload multiple files from server to client using asp.net

I need to download multiple files from server to the client using asp.net 2.0.Additionaly i would also like to disable open/save/cancel dialog box while saving the files.

Thanks in advance !!!

1 Answer

Anonymous

Level 3:

An expert who has achieved level 3 by getting 1000 points

All-Star:

An expert that got 10 achievements.

MVP:

An expert that got 5 achievements.

Vice President:

An expert whose answer got voted for 100 times.

  • Master 527 Answers
  • Posted on Aug 17, 2009
Anonymous
Master
Level 3:

An expert who has achieved level 3 by getting 1000 points

All-Star:

An expert that got 10 achievements.

MVP:

An expert that got 5 achievements.

Vice President:

An expert whose answer got voted for 100 times.

Joined: Mar 06, 2009
Answers
527
Questions
0
Helped
188157
Points
1378

Sir,


//To Get the physical Path of the file(me2.doc)
string filepath = Server.MapPath("me2.doc");

// Create New instance of FileInfo class to get the properties of the file being downloaded
FileInfo myfile = new FileInfo(filepath);

// Checking if file exists
if (myfile.Exists)
{
// Clear the content of the response
Response.ClearContent();

// Add the file name and attachment, which will force the open/cancel/save dialog box to show, to the header
Response.AddHeader("Content-Disposition", "attachment; filename=" + myfile.Name);

// Add the file size into the response header
Response.AddHeader("Content-Length", myfile.Length.ToString());

// Set the ContentType
Response.ContentType = ReturnExtension(myfile.Extension.ToLower());

// Write the file into the response (TransmitFile is for ASP.NET 2.0. In ASP.NET 1.1 you have to use WriteFile instead)
Response.TransmitFile(myfile.FullName);

// End the response
Response.End();
}

private string ReturnExtension(string fileExtension)
{
switch (fileExtension)
{
case ".htm":
case ".html":
case ".log":
return "text/HTML";
case ".txt":
return "text/plain";
case ".doc":
return "application/ms-word";
case ".tiff":
case ".tif":
return "image/tiff";
case ".asf":
return "video/x-ms-asf";
case ".avi":
return "video/avi";
case ".zip":
return "application/zip";
case ".xls":
case ".csv":
return "application/vnd.ms-excel";
case ".gif":
return "image/gif";
case ".jpg":
case "jpeg":
return "image/jpeg";
case ".bmp":
return "image/bmp";
case ".wav":
return "audio/wav";
case ".mp3":
return "audio/mpeg3";
case ".mpg":
case "mpeg":
return "video/mpeg";
case ".rtf":
return "application/rtf";
case ".asp":
return "text/asp";
case ".pdf":
return "application/pdf";
case ".fdf":
return "application/vnd.fdf";
case ".ppt":
return "application/mspowerpoint";
case ".dwg":
return "image/vnd.dwg";
case ".msg":
return "application/msoutlook";
case ".xml":
case ".sdxl":
return "application/xml";
case ".xdp":
return "application/vnd.adobe.xdp+xml";
default:
return "application/octet-stream";

Thanks
Good Luck

Add Your Answer

×

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1helpful
2answers

1. I need to connect a print server that support printing with Novell Netware 4.11...any such models available in the market. 2. Since Windows 7 does not come with support of IPX/SX is there a way to...

Greetings - Regarding Win 7 machines connecting to Netware 4.11, you need to setup TCP/IP on the server and connect Windows 7 via TCP/IP.

Regarding print servers, the tried and true HP Jetdirect Print Server series are well supported with Netware 4.11

Regards and Thanks for using Fix Ya.

Mikeywaf
0helpful
1answer

Can receive but can't send email

I can receive but can't send mail using my POP mail client. Why? If you're able to receive but unable to send mail using your POP mail client (such as Outlook), please review the possible trouble areas below.
SMTP Server
In the fight against unsolicited commercial email (spam), some Internet service providers require their subscribers to send mail through the ISP's own SMTP servers. If you experience problems sending email, please contact your ISP to determine if it requires different SMTP server settings. You will need to use the ISP's SMTP server in place of Yahoo!'s SMTP server when configuring your POP mail client.
The following is a partial list of ISPs that require you to use their SMTP servers. If your ISP is among them, try replacing the Yahoo! SMTP server with the ISP server in your POP mail client settings, or consult the ISP's help files. (Learn more about configuring your client.) If your ISP does not appear in the list below, please contact your ISP directly for more information.
MSN smtp.email.msn.com NetZero smtp.netzero.net Verizon outgoing.verizon.net Earthlink/MindSpring Please visit its help pages AT&T Please visit its help pages Bell Sympatico Please visit its help pages SBC See below SBC Your SMTP settings will vary based on your account setup. Choose the SMTP setting that corresponds to the email address most like the one provided to you by your ISP.
[email protected] smtp.ameritech.yahoo.com [email protected] smtp.flash.yahoo.com [email protected] smtp.nvbell.yahoo.com [email protected] smtp.pacbell.yahoo.com [email protected] smtp.prodigy.yahoo.com [email protected] smtp.sbcglobal.yahoo.com [email protected] smtp.snet.yahoo.com [email protected] smtp.swbell.yahoo.com [email protected] smtp.wans.yahoo.com For more information about AT&T's SMTP requirements, please visit the AT&T help center or contact AT&T DSL support at 877-SBC-DSL5 (877-722-3755) or AT&T DIAL support at 866-SBC-DIAL (866-722-3425).
SMTP Port
If you have adjusted your SMTP server, and you're still experiencing a problem, you may need to use an alternate port. In an attempt to control spam, some Internet service providers now block port 25, which means you may need to use port 587 when sending email via Yahoo!'s SMTP server. Learn how to change ports.
Antivirus Protection
If you have Norton AntiVirus enabled on your computer, you may have to make configuration adjustments to use Outlook or Outlook Express. For more information, visit the Symantec web site.
Authentication
The Yahoo! SMTP server requires authentication. Learn more.
0helpful
1answer

I have two different domains that are connected via VPN connection through two routers. I can ping from domain to domain via IP address on clients and servers. However I can only do a net view command on...

So you verified ICMP traffic isn't blocked and it appears the servers allow the netBios traffic to pass.

On the client machine, check to make sure the windows print and file sharing is installed and the machine isn't blocking netBios traffic.

Make sure TCP ports 137,139, and 445 are open on the xp machine and any devices in between.

It's acting like the TCP data is being blocked by the client machine.

HTH,
-Aaron



0helpful
1answer

I have two different domains that are connected via VPN connection through two routers. I can ping from domain to domain via IP address on clients and servers. However I can only do a net view command on...

This is an excerpt from a MS Technet page for error 53:
Resolutions: 1) if it is domain environment, check your WINS; 2) if it is peer-to-peer workgroup, enable NetBIOS over TCP/IP; 3) make sure the machine is running; 4) make sure file and Printer Share enabled on remote computer; 5) make sure client for ms networks is enabled on local computer; 6) make sure you type the correct name. 7) Make sure no firewall running or any security setting.
Pay close attention to #s 4 and 5 - I suspect XP pro might not be open enough.
2helpful
3answers

What is the use of asp.net?

ASP.NET is a free technology that allows anyone to create a modern web site.
Microsoft's site for ASP.NET
0helpful
2answers

Server system hanging

system hanging when i connect server system
0helpful
1answer

Http/1.1 internal server error

If you are running two versions of ASP.NET, you may get HTTP:/1.1 500 Internal Server Error when creating a new Web project or opening an existing Web project in Visual Studio.

This problem may occur when IIS is not sure what version of ASP.NET to use or where to locate ASP.NET files. One of the following solutions should fix the problem.

Solution 1.

  1. Remove web.config file from inetpub/wwwroot directory
  2. Go to IIS, Right click on Default web site / All tasks / Check server extensions and let it run
  3. Reset IIS by right click on IIS or call iisreset from Run command

Solution 2.

  1. Install ASP.NET again using the following command from your Run command: C:WINNTMicrosoft.NETFrameworkv1.1.4322aspnet_regiis.exe
    Make sure to change the windows folder and ASP.NET version folder with the version what you want to install
  2. Reset IIS

Solution 3. Applies to Windows Server 2003
Note: This is a Microsoft KB article:

When you try to create a new Microsoft ASP.NET 1.1 application after you change the script mapping of the existing ASP.NET 1.1 Web application to ASP.NET 1.0 on a Microsoft Windows Server 2003-based computer, you may receive the following error message:
The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/822319ev1'. 'HTTP/1.1 500 Internal Server Error'.
CAUSE
This issue occurs because Windows Server 2003 does not allow two versions of ASP.NET to run in the same application pool.
WORKAROUND
To work around the problem, do one of the following:
Restart the IIS before you create a new ASP.NET 1.1 application. At the command prompt type the following command: iisreset
OR -
Create an ASP.NET application in a separate application pool. Create the script-mapped application (ASP.NET 1.0) in a separate application pool -- for example, in the ScriptMapappPool application pool. Then, create a new ASP.NET 1.1 application in an application pool other than ScriptMapappPool. For more information about how to create an application pool, visit the following Microsoft Web site: Configuring Application Pools http://msdn.microsoft.com/en-us/library/1kdfe21k(VS.80).aspx
0helpful
1answer

Connect to a Windows Terminal Server

Yes. You need to install the RDP client software which can be downloaded from Microsoft. Procedure to install the RDP client on a MobilePro 880: Note: Steps 1 and 2 need to completed if you have not installed the Service Pack One for MobilePro 780 and 880. 1. Perform a "Hard" reset on the MobilePro 880. 2. Install NEC Service Pack 1: http://support.neccomp.com/kbtools/faq/mobilepro/mp1.asp 3. Make sure the Device Name is set to something other than "Handheld PC". 1. Start-Setting-Control Panel-Communications 2. Change Device Name to a Unique Name that is not currently being used on your network. 4. Establish a Partnership with a Host using active sync. 5. Disconnect the MobilePro from the host. 6. Install "hpcrdp.exe" on your host. It can be down loaded from Microsoft: 1. Go to http://www.microsoft.com 2. Select "Search microsoft.com" under the Search tab. 3. Type "hpcrdp" in the search box and depress Enter. 4. Look for the search results titled "Terminal Server Download for Windows CE". 5. Double click on the article and follow the link and at bottom of the Terminal Server License agreement you will find the link to bring down the RDP client. 7. Establish an Active Sync connection between the host and MobilePro 880. 8. The RDP client software will be installed on the Mobile device. 9. Install a NE2000 NIC (or any NIC that you have the MIPS CE drivers for) into the Mobile Pro 880. 10. Set up network and attach to your existing network. 11. Set up a RDP session: 1. Start-Programs-TerminalServerClient-Client Connection Wizard 2. Enter Description connection. 3. Server Name or IP address. 4. Next 5. Enter user name, password and domain if you want to logon automatically. 6. Next 7. Finish If your terminal server is set up correctly you should be able to connect as a Client.
0helpful
1answer

Software on the MobilePro system to connect to a Windows Terminal Server

Yes. You need to install the RDP client software which can be downloaded from Microsoft. Procedure to install the RDP client on a MobilePro 880: Note: Steps 1 and 2 need to completed if you have not installed the Service Pack One for MobilePro 780 and 880. 1. Perform a "Hard" reset on the MobilePro 880. 2. Install NEC Service Pack 1: http://support.neccomp.com/kbtools/faq/mobilepro/mp1.asp 3. Make sure the Device Name is set to something other than "Handheld PC". 1. Start-Setting-Control Panel-Communications 2. Change Device Name to a Unique Name that is not currently being used on your network. 4. Establish a Partnership with a Host using active sync. 5. Disconnect the MobilePro from the host. 6. Install "hpcrdp.exe" on your host. It can be down loaded from Microsoft: 1. Go to http://www.microsoft.com 2. Select "Search microsoft.com" under the Search tab. 3. Type "hpcrdp" in the search box and depress Enter. 4. Look for the search results titled "Terminal Server Download for Windows CE". 5. Double click on the article and follow the link and at bottom of the Terminal Server License agreement you will find the link to bring down the RDP client. 7. Establish an Active Sync connection between the host and MobilePro 880. 8. The RDP client software will be installed on the Mobile device. 9. Install a NE2000 NIC (or any NIC that you have the MIPS CE drivers for) into the Mobile Pro 880. 10. Set up network and attach to your existing network. 11. Set up a RDP session: 1. Start-Programs-TerminalServerClient-Client Connection Wizard 2. Enter Description connection. 3. Server Name or IP address. 4. Next 5. Enter user name, password and domain if you want to logon automatically. 6. Next 7. Finish If your terminal server is set up correctly you should be able to connect as a Client.
Not finding what you are looking for?

1,246 views

Ask a Question

Usually answered in minutes!

Top Microsoft Computers & Internet Experts

Grand Canyon Tech
Grand Canyon Tech

Level 3 Expert

3867 Answers

k24674

Level 3 Expert

8093 Answers

Brad Brown

Level 3 Expert

19187 Answers

Are you a Microsoft Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...