DiogoNeves
DiogoNeves

Reputation: 1777

How to open the default text editor from a webpage

I have a webpage (built using ASP.NET) with a list of text files. I want users to be able to click on a file and have it open using the default text editor.

It is expected that users already have the file in question, I really just have to open it.

EDIT: Only need to support Windows & Firefox & Chrome at the moment.

Upvotes: 2

Views: 1154

Answers (1)

Jeremy W
Jeremy W

Reputation: 58

The best I think you can do is force the files as downloads using the Response.ContentType with something like this:

Response.ContentType = "text/plain";
Response.AppendHeader("content-disposition", "attachment; filename=" + fileName);

If you pipe the contents of the file directly to the Response stream (thus forcing the download), it would prompt the user to save or open the file in a text editor. I think this is the closest you're going to get without inventing your own protocol.

Upvotes: 3

Related Questions