Asp.net mvc Typescript:如何在浏览器中编写响应

Asp.net mvc Typescript:如何在浏览器中编写响应,asp.net-mvc,typescript,steam-web-api,Asp.net Mvc,Typescript,Steam Web Api,类似于Response.Write()的是,它们在类型脚本中的任何等价语法 我正在从typescript调用web api,它返回httpResponse消息,内容为文件附件,但我希望通过typescript在浏览器中打开该附件文件 Public DownloadFile() { var content = //Web API result //Neeed to render this above content in browser } 一

类似于Response.Write()的是,它们在类型脚本中的任何等价语法

我正在从typescript调用web api,它返回httpResponse消息,内容为文件附件,但我希望通过typescript在浏览器中打开该附件文件

Public DownloadFile()
{
      var content = //Web API result        
      //Neeed to render this above content in browser      
}
一个简单的方法是:

如果有多行结果:

$('<p>').text('result 1').appendTo($(document.body));
$('<p>').text('result 2').appendTo($(document.body));
并像这样称呼它:
this.write(document.body,['result 1','result 2'])

如果只想在控制台中查看结果,可以编写
console.log('result 1','result 2')
。通过按F12键,您可以在类似Google Chrome Developer的控制台中看到结果

$(document.body).text(‘Result 1’);
$('<p>').text('result 1').appendTo($(document.body));
$('<p>').text('result 2').appendTo($(document.body));
write(element: JQuery, text: string[]) {
            text.forEach(v => {
                $('<p>').text(v).appendTo(element);
            });
        }
write(element: HTMLElement, text: string[]) {
            text.forEach(v => {
              document.body.innerHTML += v + '<br>';
            });
        }