[英]Display specific record when link in email is clicked
how do I include a link in an email that when clicked it would display data for one record only?如何在电子邮件中包含一个链接,单击该链接时它只会显示一条记录的数据?
Right now I have a datatable in the index page that displays all records when the app opens up.现在,我在索引页中有一个数据表,它在应用程序打开时显示所有记录。 When a change to a record is made an email is sent out with the id number of the record that was edited.当对记录进行更改时,会发送一封带有已编辑记录的 ID 号的电子邮件。
I am supposing I have to create another view just for this?我想我必须为此创建另一个视图? I was thinking I need to implement a GET action in a controller that accepts id as a parameter, searches the underlying data store and returns appropriate record.我在想我需要在接受 id 作为参数的控制器中实现一个 GET 操作,搜索底层数据存储并返回适当的记录。
Also, I found this Open Specified ASP.NET MVC Views From Hyperlinks Inside Email Body but I cannot quite understand what is going on as there is login stuff and other things involved as well.另外,我发现这个Open Specified ASP.NET MVC Views From Hyperlinks Inside Email Body但我不太明白发生了什么,因为还有登录和其他事情。
How do I go about this as I have never done it before?我以前从未这样做过,我该怎么做? Could you please provide some example code?你能提供一些示例代码吗? Thanks a lot.非常感谢。
This is the code i have so far which works but it is missing the piece i am asking for:这是我到目前为止有效的代码,但它缺少我要求的部分:
[HttpPost]
public ActionResult EditOneRecord(Ticket tix, string action, string confirm_value)
{
if (action == "Save")
{
using (DBModel db = new DBModel())
{
//Send email to user if IT edits the record
if (userName != tix.vcAssignedTo)
{
SmtpClient client = new SmtpClient();
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("nsantagata@fieldaero.com");
mailMessage.To.Add("nsantagata@fieldaero.com");
mailMessage.Subject = "Your Ticket Has Been Edited";
mailMessage.Body = "Your ticket " + tix.iNumber + " has been updated";
client.Send(mailMessage);
}
db.Entry(tix).State = EntityState.Modified;
tix.dtLastUpdated = System.DateTime.Now;
try
{
db.SaveChanges();
}
catch (Exception)
{
throw;
}
}
//Save to knowledgebase
if (confirm_value == "Yes")
{
HelpDeskDBHandle HDdb = new HelpDeskDBHandle();
if (HDdb.AddKnowledgeBase(tix))
{
}
}
return RedirectToAction("Index");
}
else
{
return RedirectToAction("Index");
}
}
You can add an optional param.您可以添加一个可选参数。 if he has a value then you sort by it, else you will return the page as is.如果他有一个值,那么你按它排序,否则你将按原样返回页面。
return RedirectToAction("Index?id=1212");
some thing like this.像这样的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.