Browsers Try to Download HTML File Instead of Opening

Browsers try to download html file instead of opening

Likely an incorrect mime type in your .htaccess file. I suggest going into it and looking for any unwanted lines similar to the below and removing them.

AddHandler application/ etc.

and also ensure your type is set as follows:

AddType text/html .html

In order to open .htaccess in cPanel:
Click File Manager and make sure to tick Show Hidden Files (dotfiles) before clicking Go. Then the .htaccess should show up the location where wp (wp-admin, wp-content, wp-includes) is installed.

Browser downloads the html file instead of opening

I do not know what is the exact problem here. But I got to know that it has to do something with content type as td-lambda mentioned in the comments. So I found a solution like this.

var express = require('express');
var app = express();
var server = app.listen(8080);
app.set({
'Content-Type': 'text/html'
});
app.use(express.static(__dirname + '/public'));

And this solved my problem.

Browser downloads the file instead of showing html

try this (you forgot to add the listen callback, and a typo in content type):

var http = require('http');
var port = 9000;
http.createServer(function(req,res){
res.writeHead(200,{'Content-Type':'text/plain'});
res.end('Hello world!\n');
}).listen(port, err => {
if (err) throw err
console.log('Listening on port',port);
})

npm http-server downloads index.html instead of serving

Use this URL http://127.0.0.1:8080/

instead of localhost:8080

(HTML) Download a PDF file instead of opening them in browser when clicked

There is now the HTML 5 download attribute that can handle this.

I agree, and think Sarim's answer is good (it probably should be the chosen answer if the OP ever returns). However, this answer is still the reliable way to handle it (as Yiğit Yener's answer points out and--oddly--people agree with). While the download attribute has gained support, it's still spotty:

http://caniuse.com/#feat=download

Whenever I click a link, It downloads an empty html file instead of opening another page

change your view to render the template:

def update(request):
return render(request, 'taskapp/update.html')

Opening files in browser instead of downloading

add target="_blank" to get a new window. adding .pdf may help. If you have control over the host web server adjusting the headers for the files in question will also help it open inline. I can tell you what headers to set if you are able too

Chrome is downloading HTML files instead of displaying them

As far as I know, chrome download the html page is right. Since you use chrome to access a ftp file, it is not a http connection to the server. The chrome will not directly show it.

If you want to show the html page in the browser, you should use IIS website instead of ftp site.

More details about how to create a IIS web site, you could refer to below article.
https://support.microsoft.com/en-sg/help/323972/how-to-set-up-your-first-iis-web-site



Related Topics



Leave a reply



Submit