Click here to Skip to main content
15,899,025 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Error Webservice (hexadecimal value 0x0E, is an invalid character) Pin
Not Active30-Jan-11 6:41
mentorNot Active30-Jan-11 6:41 
AnswerRe: Error Webservice (hexadecimal value 0x0E, is an invalid character) Pin
Dalek Dave4-Mar-11 13:23
professionalDalek Dave4-Mar-11 13:23 
Questionput logo in crystal reports Pin
Thanusree Duth28-Jan-11 19:09
Thanusree Duth28-Jan-11 19:09 
AnswerRe: put logo in crystal reports Pin
Sandeep Mewara28-Jan-11 19:41
mveSandeep Mewara28-Jan-11 19:41 
AnswerRe: put logo in crystal reports Pin
sund7wells1-Feb-11 19:56
sund7wells1-Feb-11 19:56 
QuestionStyle Points Pin
Bomb_shell28-Jan-11 10:21
Bomb_shell28-Jan-11 10:21 
AnswerRe: Style Points Pin
David Mujica28-Jan-11 10:42
David Mujica28-Jan-11 10:42 
QuestionMVC File Download Pin
musefan28-Jan-11 5:34
musefan28-Jan-11 5:34 
Hi All,

I am developing an MVC web application and one of the pages allows for an attachment to be uploaded. Once uploaded, it is saved in a database field as binary data. Any attachments are then shown on a page as links.

When a user clicks a link it directs to an Action that returns a FileContentResult. In general the process is working but it is not quite what I want. Basically, what I want to achieve is as follows...

1. If the user clicks the link, the browser will attempt to open the file, if it cannot open then it prompts for save as...
2. The user can right-click and select "Save Link As.." (or whatever you browser calls it) and can download the file. The requirement here is to provide a default file name based on the file name of the attachment

...I can get both working but not together. This is two "simplified" variations of my function (found in a controller) which produce the two results...


1. Click link opens, right click prompts (but default file name is chosen by browser = "download.pdf")

public ActionResult DownloadFile()
{
   //get file data
   return File(fileByteArray, fileContentType);
}


2. Click link prompts, right click prompts (default file name is correctly set)

public ActionResult DownloadFile()
{
   //get file data
   return File(fileByteArray, fileContentType, "filename.pdf");
}


...So it seems that by using the overload which allows to specify the file name, I am sacrificing the ability to open the file in the browser. But I want both!

Any ideas?

Thanks
return 5;

AnswerRe: MVC File Download Pin
TheGreatAndPowerfulOz28-Jan-11 10:05
TheGreatAndPowerfulOz28-Jan-11 10:05 
GeneralRe: MVC File Download Pin
musefan28-Jan-11 10:37
musefan28-Jan-11 10:37 
Questionopen a pop up window Pin
vishnukamath28-Jan-11 2:18
vishnukamath28-Jan-11 2:18 
AnswerRe: open a pop up window Pin
Pete O'Hanlon28-Jan-11 3:00
mvePete O'Hanlon28-Jan-11 3:00 
GeneralRe: open a pop up window Pin
musefan28-Jan-11 5:38
musefan28-Jan-11 5:38 
QuestionMVC for big applications Pin
slSoftware28-Jan-11 1:57
slSoftware28-Jan-11 1:57 
Questionsen mail in asp .net 2.0 Pin
Thanusree Duth27-Jan-11 0:12
Thanusree Duth27-Jan-11 0:12 
AnswerRe: sen mail in asp .net 2.0 Pin
Yusuf27-Jan-11 0:55
Yusuf27-Jan-11 0:55 
AnswerRe: sen mail in asp .net 2.0 Pin
Gandalf_TheWhite27-Jan-11 1:25
professionalGandalf_TheWhite27-Jan-11 1:25 
AnswerRe: sen mail in asp .net 2.0 Pin
RaviRanjanKr27-Jan-11 3:42
professionalRaviRanjanKr27-Jan-11 3:42 
GeneralRe: sen mail in asp .net 2.0 Pin
Thanusree Duth27-Jan-11 18:37
Thanusree Duth27-Jan-11 18:37 
AnswerRe: sen mail in asp .net 2.0 Pin
musefan28-Jan-11 6:17
musefan28-Jan-11 6:17 
QuestionIs it possible that userConfrol was called before mainpage? Pin
buffering8326-Jan-11 14:21
buffering8326-Jan-11 14:21 
AnswerRe: Is it possible that userConfrol was called before mainpage? Pin
fjdiewornncalwe26-Jan-11 15:05
professionalfjdiewornncalwe26-Jan-11 15:05 
AnswerRe: Is it possible that userConfrol was called before mainpage? Pin
Yusuf27-Jan-11 0:57
Yusuf27-Jan-11 0:57 
Questionhttpcontext Pin
Ramkumar_S25-Jan-11 15:06
Ramkumar_S25-Jan-11 15:06 
AnswerRe: httpcontext Pin
Not Active25-Jan-11 15:20
mentorNot Active25-Jan-11 15:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.