我是asp.net core mvc的新手。我想做的是将视图模型绑定到视图。在“获取请求”中,它工作正常,但是在“发布请求”并将其传递给视图之后,尽管我的视图模型具有值,但仍然不显示任何内容。
这就是我所做的。
def arp_analys(filename):
with open("../data/" + filename + ".pcap", 'rb') as f:
pcap = dpkt.pcap.Reader(f)
requests = []
replies = []
for ts, buf in pcap:
eth = dpkt.ethernet.Ethernet(buf)
# If the packet is not arp
if eth.type != 2054:
continue
try:
arp = eth.arp
except Exception as e:
continue
packet_time = datetime.datetime.utcfromtimestamp(ts).strftime("%m/%d/%Y,%H:%M:%S")
src = dpkt.socket.inet_ntoa(arp.spa)
tgt = dpkt.socket.inet_ntoa(arp.tpa)
# Src and Dest MAC
from src.arpbasic import mac_addr
s_mac = mac_addr(eth.src)
d_mac = mac_addr(eth.dst)
在我看来
[HttpGet]
public IActionResult Tito()
{
return View();
}
[HttpPost]
public IActionResult Tito(AttendanceViewModel model, string submit)
{
model.AccountModelId = HttpContext.Session.GetString("myaccountid");
model.IsTimeIn = submit == "timein" ? true : false;
model.DateFrom = DateTime.Now;
Tuple<bool,DateTime> result = this.service.LogAttendance(model);
if (result.Item1 == true)
{
return View(model);
}
return View();
}
应在发布请求后显示日期时间,但不显示。
答案 0 :(得分:0)
确保模型的输入具有“名称”属性。尝试添加:
name="Model.PropertyName"
到您的输入标签
或者尝试使用包含的帮助方法,例如@ Html.EditorFor()https://www.tutorialsteacher.com/mvc/htmlhelper-editor-editorfor