I have a Web Method that creates a file and gives it to the browser.
In Chrome the text file just downloads.
In IE9 the browser asks me if I want to open or save the file.
What I want to do is for the browser to automatically open the file (in the default program for that file type)
Code:
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public void Test(string docNum, string docVersion)
{
var response = Context.Response;
response.ContentType = "application/octet-stream";
response.AppendHeader("Content-Disposition", "attachment; filename=" + docNum + ".txt");
Byte[] stream = System.Text.Encoding.ASCII.GetBytes("docNum + "," + docVersion);
response.OutputStream.Write(stream, 0, stream.Length);
response.Flush();
}
I envoke it via:
http://localhost:12345/Services/Foo.asmx/Test?docNum=123456789&docVersion=1
How can I get the browser to just open the file?