【发布时间】:2020-05-15 18:38:15
【问题描述】:
我的视图中有一个 Facebook 分享按钮,
<div class="fb-share-button"
data-href="https://localhost:5001/venue/details/@Model.Id"
data-layout="button_count" data-size="large">
<a href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Flocalhost%3A5001%2Fvenue%2Fdetails%2F@Model.Id%3Fq%3Dgaurav-acharya&src=sdkpreparse" class="fb-xfbml-parse-ignore">
Share
</a>
</div>
所以当用户点击它时,我想在我的数据库的共享表中保存一些数据,假设我想调用控制器方法“https://localhost:5001/venue/share?vid=88。
在我的控制器中,我有
public void Share(int vid)
{
Share share = new Share();
share.UserName = GetUserName(_userManager);
share.VenueId = vid;
Console.WriteLine(vid);
_context.Shares.Add(share);
_context.SaveChanges();
}
【问题讨论】:
标签: javascript html asp.net-mvc model-view-controller .net-core