Servicestack return wrong content type when returning a file with html extension -
i testing servicestack rest files service. when calling angularjs , asking html file back, results comes standard servicestack html format instead of json format. when appending ?format=json, not work correctly. trying browse html files , trying load ace editor. think servicestack getting confused response type. checked , content-type set application/json on client side when doing request.
i'm assuming request you're making is:
get /files/myfile.html it's returing html because .html file extension built-in registered format in servicestack assumes you're explicitly requesting api in html format.
you can avoid ambiguity specifying file path on querystring, e.g:
get /files?path=myfile.html which tells servicestack send using appropriate format specified in accept header. or if prefer can explicitly specify format adding {.ext} @ end of path info, e.g:
get /files.json?path=myfile.html another option, if you're not using servicestack's built-in html support remove htmlformat plugin, e.g:
plugins.removeall(x => x htmlformat); whicih make .html no longer registered format .html extension benign.
note: removing htmlformat removes built-in html functionality auto html pages
Comments
Post a Comment