I have a MVC project that allows users to upload files to their account and make them accesible through a link to the filepath on a datatable, when the user uploads their content the file gets renamed based on the original name and a timestamp:
if (uploadedF.ContentLength > 0)
{
InputFileName = Path.GetFileName(uploadedF.FileName);
ServerSavePath = string.Concat(Server.MapPath("~/filesUP/") + YMD + "_" + fHM + "_" + InputFileName);
//Save file to server folder
uploadedF.SaveAs(ServerSavePath);
}
Then the ServerSavePath variable gets stored in the SQL Database as is, so the url is like so:
C:\inetpub\wwwroot\projectname\filesUP\20200309_1047_filename.jpg
Calling the link to the datatable:
{
"data": "fileUrl",
"render": function (data, type, row, meta) {
if (type === 'display') {
data = '<a href="' + data + '">' + 'Check Document' + '</a>';
}
return data;
}
}
And the browser shows the path like this:
file:///C:/inetpub/wwwroot/projectname/filesUP/20200309_1047_filename.jpg
When clicking the link the browser does nothing but opening it on a new tab the url looks like this on Chrome about:blank#blocked
.
IIS has all rights to access the project folders, tried debugging and the problem persists either way. Is there other way to access a file directly from the browser?