asp.net - Browser fails to recognise Content Type header correctly -


There is a problem with my browser that fails to identify content types, I am sending in my replies and its Instead of trying to download the file,

I have a general handler (named SPARQL.ashx) that are written in ASP.NET which works for something and There are two possible types of which it produces. Either it receives a SPARQLResultSet or a graph and then sets the appropriate content type before using the appropriate method to send content to the user. Code section is below:

  // execute query object = store.ExecuteQuery (sparqlquery); If (the result is SPARQLResultSet) {// SPARQL return results as XML format references. Response Content Type = MIMETypesHelper.SPARQL [0]; SPARQLResultSet resultet = (SPARQLResultSet) results; Resultset.Save (new StreamWriter (context.Response.OutputStream)); } And if (the result is graph) {// Return as Turtle Reference. Response Contact Type = MIMETypesHelper.Turtle [0]; Graph G = (graph) result; TurtleWriter ttlwriter = New TurtleWriter (); Ttlwriter.PrettyPrintMode = True; Ttlwriter.Save (g, new streamer (reference.response.OutputStream)); }  

My issue is that my browser will often prompt to download results instead of displaying that a format is XML based and other plain text is based and therefore both are displayed Should be done in any modern browser

Behavior changes from browser to browser and for some download formats no matter what it will be downloaded and some will be for one but other Not.

Do I need to configure IIS somehow to make sure the correct mime types have been sent. The official file extensions and mime types registered for IIS are for records, or is it an issue with the fact that I am using generic handlers?

Edit

The code added to MIMEType hyper class for clarity

  /// & lt; Summary & gt; /// Helper Class in which various MIDF type ARDs for RDF concrete syntax include & lt; / Summary & gt; /// & lt; Comment & gt; The first type of canon type in each array is to be used & lt; / Remark & ​​gt; Public class MIMETypesHelper {/// & lt; Summary & gt; / MIME type for Turtle /// & lt; / Summary & gt; Public static string [] turtle = {"text / turtle", "app / x-turtle", "app / turtle"}; /// & lt; Summary & gt; /// RDF / XML /// & lt; / Summary & gt; Mime type public static string [] RDFXML = {"Application / RDF + XML"}; /// & lt; Summary & gt; /// MIME type 3 /// for notification. / Summary & gt; Public stable string [] notation 3 = {"text / n3", "text / rdf + n3"}; /// & lt; Summary & gt; NT / MIME type of NT /// & lt; / Summary & gt; Public stable string [] NTriples = {"text / plain"}; /// & lt; Summary & gt; /// MIME type for the SPARQL results group /// & lt; / Summary & gt; Public static string [] SPARQL = {"application / sparkle-result + xml"}; ///e.t.c. }    

From your code it seems that you are relying on mimetypes in rdf library (What you do not say) when a browser like Firefox / IE (you do not say what you're using) sees a mime type application / some It usually offers to see it instead of saving it.

The type of mime type for RDF / XML is application / rdf + xml (I know, because I wrote space) and this would be the reason for the prevention of turtles Mime type (which I created) is not registered but it was suggested to be text / turtle , which should look fine.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -