我有一个控制器
public class InvitationController : Controller
{
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Create(InvitationModel invitationmodel)
{
if (ModelState.IsValid)
{
var regLink = _repo.SaveAndGetRegistrationLink(invitationmodel);
IEMailer mailer = new EMailer();
var inv = mailer.Invitation(invitationmodel.Email, regLink);
await Task.WhenAll(new AsyncEmailSender().SendEmail(inv));
return RedirectToAction("Index");
}
return View(invitationmodel);
}
}
它在我的本地主机上运行良好(发送电子邮件后重定向到所需的页面)。我将我的网站发布到 smarterasp.net
现在它显示一个字符串而不是重定向:
System.Threading.Tasks.Task`1[System.Web.Mvc.ActionResult]
是什么原因,如何解决?
Elmah 没有记录任何东西。电子邮件实际上已发送。
我尝试添加 MVC dll。下面的所有文件都位于我的网站 dll 旁边。
- 系统.Web.Mvc
- Microsoft.Web.Infrastructure
- System.Web.Razor
- System.Web.WebPages
- System.Web.WebPages.Razor
- System.Web.Helpers
编辑
主机管理员从 iis 向我发送了一条日志:
Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
StackTrace: at System.Web.ThreadContext.AssociateWithCurrentThread(Boolean setImpersonationContext)
at System.Web.HttpApplication.OnThreadEnterPrivate(Boolean setImpersonationContext)
at System.Web.LegacyAspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback callback, Object state)
at System.Web.LegacyAspNetSynchronizationContext.CallCallback(SendOrPostCallback callback, Object state)
at System.Web.LegacyAspNetSynchronizationContext.Post(SendOrPostCallback callback, Object state)
at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.PostAction(Object state)
at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(ContextCallback callback, Object state, Task& currentTask)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.AwaitTaskContinuation.<ThrowAsyncIfNecessary>b__1(Object s)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()