Opera and Safari not recognizing vCard mimeType for dynamically generated vCards...

We have a ASHX response handler that dynamically generates .VCF files on the fly and delivers them as ContactLisa.vcf.  Internet Explorer and FireFox recognize the results properly (views the mimetype as text/vCard and saves the file as ContactLisa.vcf).    However both Opera and Safari view the response as "GenerateVCard.ashx" and saved it as such...and ignores the mimeType.  

The content of the saved file is the vCard data so the script is running properly.  

How can we get Opera and Safari to properly recognize the vCard mimetype and save the results as a .VCF file?
Here is the part of the code where we set the mimetype and appropriate headers:
 
context.Response.BufferOutput = true;
context.Response.ContentType = "text/x-vcard";
context.Response.AddHeader("content-disposition", "attachment; filename=ContactLisa.vcf");
context.Response.AddHeader("content-description", "vCard");

Open in new window

sggexchangeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DropZoneCommented:
Try clearing the headers and the entire buffer before setting the new headers.  It could be that there is something extra there that those browsers do not like.  Can you post the entire HTTP header output of the above code?

   -dZ.
0
sggexchangeAuthor Commented:
Thanks for the advice but clearing the headers did not work....here is what our script is passing back...complete response with headers and content.  Any ideas?  Thanks!

HTTP/1.1 200 OK
Connection: close
Date: Tue, 29 Jan 2008 20:06:04 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
content-disposition: attachment; filename=OrlandoViolinist.vcf
content-description: vCard
Cache-Control: private
Content-Type: text/x-vcard; charset=utf-8

Content-Length: 512

BEGIN:VCARD
VERSION:2.1
N:Ferrigno; Lisa;;;
FN: Lisa Ferrigno
ORG: ;
TITLE:Orlando Violinist
NOTE;ENCODING=QUOTED-PRINTABLE:This is a note associated with this
contact=0D=0A
TEL;WORK;VOICE:(407) 123-4567
TEL;HOME;VOICE:
TEL;CELL;VOICE:
TEL;WORK;FAX:
ADR;WORK:;;P.O. Box 3603;Winter Park;FL 32790;;USA
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:P.O. Box 3603=0D=0AWinter Park, FL
32790 =0D=0AUSA
URL:lfv.sggportfolio.com
URL:lfv.sggportfolio.com
EMAIL;PREF;INTERNET:mkt@sggmail.test
REV:
END:VCARD


0
DropZoneCommented:
I just tried the following page, saved as "index.aspx", in Opera and it works as expected:

------ START index.aspx
<%@ Page Language="c#" %>
<%
      HttpContext.Current.Response.BufferOutput = true;
      HttpContext.Current.Response.ContentType = "text/x-vcard";
      HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=Contact.vcf");
      HttpContext.Current.Response.AddHeader("Content-Description", "vCard");
%>
BEGIN:VCARD
VERSION:2.1
N:Ferrigno; Lisa;;;
FN: Lisa Ferrigno
ORG: ;
TITLE:Orlando Violinist
NOTE;ENCODING=QUOTED-PRINTABLE:This is a note associated with this
contact=0D=0A
TEL;WORK;VOICE:(407) 123-4567
TEL;HOME;VOICE:
TEL;CELL;VOICE:
TEL;WORK;FAX:
ADR;WORK:;;P.O. Box 3603;Winter Park;FL 32790;;USA
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:P.O. Box 3603=0D=0AWinter Park, FL
32790 =0D=0AUSA
URL:lfv.sggportfolio.com
URL:lfv.sggportfolio.com
EMAIL;PREF;INTERNET:mkt@sggmail.test
REV:
END:VCARD
------ END


This was using Windows XP, and .NET 2.0.  Can you confirm that the above does not work for you?

    -dZ.
0
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

sggexchangeAuthor Commented:
Afraid it still doesn't work for us using Opera or Safari.   The content attachment filename "contact.vcf" is not retained and the file still saves as an ASPX page (and opens in Visual Studio).

In FireFox and IE it is fine...as our script was before.  

 In Safari on a Mac (our client has a Mac which is why we are scrambling to make this work), the address book can't recognize the file and says:  No importable cards were found.

Do you have any other ideas?  I appreciate the help!  
0
DropZoneCommented:
I haven't tried it on a Mac, but I don't doubt that the problem exists.  It's strange that it doesn't work on Safari and Opera, which are some of the best standards-compliant browsers.  I don't really see *anything* wrong with the output you posted.

Try changing the Content-Type to the generic binary type:  "application/octet-stream".  However, this means that the AddressBook application won't be able to open it automtically.

Try adding this:
<%
      HttpContext.Current.Response.BufferOutput = true;
      HttpContext.Current.Response.ContentType = "text/x-vcard; name="Contact.vcf"";
      HttpContext.Current.Response.AddHeader("Content-Transfer-Encoding", "7bit")
      HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=Contact.vcf");
      HttpContext.Current.Response.AddHeader("Content-Description", "vCard");
%>

Which versions of Safari and Opera are you using anyway?  It could be that they are not set up to support that MIME type.

    -dZ.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sggexchangeAuthor Commented:
Thanks for taking a shot at this.  We ended up ditching the dynamic generation part of the vcards in favor of just putting real vcards on the site.  The contact information will probably never change anyway.

Thanks for the help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.