Net Core MVC 并试图让我的应用程序读取文本文件,但是当我单击“获取”按钮时,它不会激活相应的 IActionResult,我可能做了一些明显错误的事情,所以任何帮助将不胜感激。这是我的视图和控制器的相关代码。看法 @{ ViewData["Title"] = "Home Page"; }<div class="text-center"> <h1 class="display-4">Welcome</h1> <p>Please Upload An Excel File.</p> <input type="file" name="datafile" style="margin-left: 10px; margin-top: 15px; vertical-align: top; font-size:18px; background-color: white; margin-left:160px; margin-top:15px; width:250px; height:40px /"></div><form method="get" asp-controller="Home" asp-action="Log"> <div class="form-group"> <p>Read</p> <input type="button" value="Read" /> </div></form>控制器:[HttpGet]public IActionResult Log(){ var webRoot = _env.WebRootPath; var file = Path.Combine(webRoot, "Output,txt"); //var lines = System.IO.File.ReadAllText() System.IO.File.ReadAllText(file); return Content(file); }
- 1 回答
- 0 关注
- 78 浏览
添加回答
举报
0/150
提交
取消