I have a problem to create a correct download link for a file.
This is the expected and working result (correct path): http://localhost:60000/ManualMeterDocuments/client/Exports/client_0985-20160318-211554.xlsx
But this is what MVC makes of it: http://localhost:60000/ManualMeters/~/ManualMeterDocuments/client/Exports/client_0985-20160318-211554.xlsx
ManualMeters/ => the controller.
In my controller action at a point I get the physical path: C:\Data\Test\source\Portal\Portal\ManualMeterDocuments\Client\Exports\Client_0985-20160318-214256.xlsx and try to return the relative path.
I've tried different things but can't get it right.
var virtualFilePath = exportFile.Replace(Server.MapPath("~"), "~/");
return Json(virtualFilePath, JsonRequestBehavior.AllowGet);
This is the value in the var virtualFilePath returned from the controller to jquery ajax call. From there I bind it to a <a>
href tag:
ManualMeterDocuments\Client\Exports\client_0985-20160318-215243.xlsx
So that path is ok, but somehow somewhere ManualMeters/ is added to the link.
EDIT: this is what I should be able to put in the href attribute to get the download working: test