I have small Asp MVC 3 project where I need to create link to file, but I don’t know what the name of the site will be.
So in my ActionResult I need to have next
public ActionResult LinkToFile()
{
var fields = new[]{
new { type = "string", name = "name" , title = "Name"} ,
new { type = "string" , name = "link" , title = "Link" }
};
var meta = new { fields };
var data = new[]
{
new
{
name = "PDF file",
link = http://example.com/files/file.pdf
}
};
var res = new { contentType = "LinkToFile", id = 1, meta, data };
return Json(res, JsonRequestBehavior.AllowGet);
}
As I said before, I don’t know what the name of the site will be, where I can this: http://example.com ?
The file is located on the server in folder name “file”
http://www.cambiaresearch.com/articles/53/how-do-i-get-paths-and-url-fragments-from-the-httprequest-object
There’s the whole list i gues 🙂