Request.QueryString get请求
Request.QueryString查询字符串
Request.Form post请求
Request.MapPath()将虚拟路径转换成物理路径(SaveAs)
上传文件
html代码
<form action="/Home/FileData" method="post" enctype="multipart/form-data">
<input type="file" name="file" />
<button>提交</button>
</form>
”SaveAs需要物理路径“
cs代码
public ActionResult FileData()
{
Request.Files["file"].SaveAs(filename: Request.MapPath("~/uploads/" + Request.Files["file"].FileName));
return Content("ok");
}
Response.Write 向客户端输出内容
Response.Redirect 重新定向另一个路径
public ActionResult ResponseData()
{
Response.Write(s: "Hello World");
Response.Redirect(url: "http://www.baidu.com");
return Content("");
}