我正在查看postmarkapp.com来处理使用他们提供的.net库从我的asp.net mvc 2应用程序发送电子邮件:postmark-dotnet library
在他们的文档中,他们提到发送带有附件的电子邮件可能需要一些时间,而且最好在后台工作中执行此操作.对于我的应用程序,我可以向我的用户发送10到500个个性化电子邮件,其中一些带有附件.
以非阻塞方式对在ASP.Net MVC中启动创建和发送这些电子邮件的管理员用户进行后台处理的最佳方法是什么?
如果他们点击"创建并发送电子邮件"给500个用户并在该过程完成之前关闭浏览器会发生什么?
谢谢你的帮助!ASP.Net MVC的新功能
我正在尝试使用包含在ViewModel中的特定batchId参数转到视图,选择要上载的文件,获取上载的文件并将文件数据与关联的BatchId值一起存储在数据库中.
提交表单时,我不知道如何取回viewmodel和PostedFileBase,以便我可以获取BatchId值.
我需要batchId值将它与我存储在数据库中的数据相关联.
我的控制器中有以下操作方法,允许通过文件上载和导入将新客户添加到指定的批处理:
public ActionResult AddCustomers(int batchId)
{
var viewModel = new AddCustomersViewModel() { BatchId = batchId, //other view model properties };
return View(viewModel);
}
Run Code Online (Sandbox Code Playgroud)
我的视图是强类型的ViewModel:
Inherits="System.Web.Mvc.ViewPage<TestExcelImport.Areas.Admin.ViewModels.AddCustomersViewModel>
Run Code Online (Sandbox Code Playgroud)
并具有以下文件上传:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>AddCustomers Batch ID : <%:Model.BatchId %></h2>
<form action="/Admin/Dashboard/AddCustomers" enctype="multipart/form-data" method="post">
<input type="file" id="SourceFile" name="SourceFile" />
<br />
<input type="submit" value="Send" name="btnUpload" id="Submit1" />
</form>
</asp:Content>
Run Code Online (Sandbox Code Playgroud)
我的HttpPost Action方法定义为:
[HttpPost]
public ActionResult AddCustomers(HttpPostedFileBase SourceFile)
{
//int batchId = ??? HOW DO I Get the BatchId
int fileLength = SourceFile.ContentLength; …Run Code Online (Sandbox Code Playgroud) 我有两种类型的角色[Admin,HelpDeskAdmin].
我有一个登录视图(两个用户都转到相同的登录链接),我想在登录后检查他们的角色,并在经过身份验证后重定向到各自的管理页面.下面的代码不会将登录用户标识为第一次处于角色中并重新加载登录页面,第二次登录时它会正确地重定向.
这是否与第一次检查时没有到位的身份验证cookie有关?我怎么能完成这个场景?
[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (MembershipService.ValidateUser(model.UserName, model.Password))
{
FormsService.SignIn(model.UserName, model.RememberMe);
if (!String.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
else
{
if (Roles.IsUserInRole("Admin"))
{
//go to admin landing page
return RedirectToAction("Index", "Manage");
}
else if (Roles.IsUserInRole("HelpDesk"))
{
//go to helpdesk landing page
return RedirectToAction("Index", "Interview");
}
else /******FIRST TIME THROUGH IT ALWAYS GOES HERE *******/
return RedirectToAction("Index", "Home"); //not in any of those roles
}
}
else
{
ModelState.AddModelError("", "The user name or …Run Code Online (Sandbox Code Playgroud)