Forum Moderators: open

Message Too Old, No Replies

Using application/vnd.ms-excel

seems to cause permissions issue

         

Easy_Coder

6:57 pm on Jan 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've got this c# page that calls a webservice, gets back a dataset that gets dumped to the browser as excel by setting the content type to "application/vnd.ms-excel"

Most users get a file download dialog and can choose to save the file locally which works like a champ but some users choose to open the file in their browser. This works perfectly fine until the user then attempts to File ¦ Save As. If they do that then the server prompts for Netword Security Credentials. Too, some users don't even receive a file download dialog, sometimes the browser will bypass that and immediately open the file.

Any ideas why that would be occurring? IUSR has read and the aspnet user has the whole enchalada. How can I force the file download dialog to appear too?

Code looks like this (assume all paramater variables are set accordingly)
ws.webservice et = new ws.webservice();

DataSet vDataSet = et.GetResportAsXml(_userName, _passWord, _manId, _startDate, _endDate, true);
dg.DataSource = vDataSet;
dg.DataBind();

System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);

dg.RenderControl(htmlWrite);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
Response.Write(stringWrite.ToString());
Response.End();

Easy_Coder

8:41 pm on Jan 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Looks like the issue is with excel not being marked safe for scripting in ie. I had to drop the domain into trusted sites where the security level is low.

FireFox handles this differently and a little smoother... ff doesn't display the excel directly in the browser rather it locates the application assosciated with the content type and asks the user if they want to open the file with that program or you get the option to browse to another program.