Net Core MVC 并試圖讓我的應用程序讀取文本文件,但是當我單擊“獲取”按鈕時,它不會激活相應的 IActionResult,我可能做了一些明顯錯誤的事情,所以任何幫助將不勝感激。這是我的視圖和控制器的相關代碼??捶?nbsp;@{ 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 關注
- 102 瀏覽
添加回答
舉報
0/150
提交
取消