在MVC中,我们使用以下代码下载文件.在ASP.NET核心中,如何实现这一目标?
HttpResponse response = HttpContext.Current.Response;
System.Net.WebClient net = new System.Net.WebClient();
string link = path;
response.ClearHeaders();
response.Clear();
response.Expires = 0;
response.Buffer = true;
response.AddHeader("Content-Disposition", "Attachment;FileName=a");
response.ContentType = "APPLICATION/octet-stream";
response.BinaryWrite(net.DownloadData(link));
response.End();
Run Code Online (Sandbox Code Playgroud) 在ASP.NET Web窗体中,我能够使用Ajax"post"请求调用页面方法.但我无法使用"获取请求"调用页面方法.
在这种情况下,是否可以使用"获取"请求调用页面方法.您能否提供任何建议?页面方法的示例代码:
[WebMethod]
public static string GetData()
{
return "test";
}
Run Code Online (Sandbox Code Playgroud) ASP.NET中的“剃须刀”和“ cshtml”文件有什么区别?我们是否应该在“ razor-components”应用程序中使用“ .razor”文件而不是cshtml?