亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

.Net Core Get 不被擊中

.Net Core Get 不被擊中

C#
慕虎7371278 2023-09-09 17:30:12
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 回答

?
搖曳的薔薇

TA貢獻1793條經驗 獲得超6個贊

您應該使用按鈕的提交類型

   <input type="submit" value="Read" />

但我建議你將操作更改為 HttpPost


查看完整回答
反對 回復 2023-09-09
  • 1 回答
  • 0 關注
  • 102 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號