【发布时间】:2015-04-22 13:05:50
【问题描述】:
我应该从解决方案中的另一个项目调用邮件控制器的动作,动作看起来像这样:[控制器名称是ServiceMailController,动作名称是SendNotification,只是就像在调用者中一样。]
[AllowAnonymous]
[HttpPost]
public ActionResult SendNotification(string MemberId, string Email, string Name, string RedirectUrl)
{
bool isSent = false;
try
{
Member member = MemberProvider.Instance.GetItem(ObjectId.Parse(MemberId));
NotificationEmailModel model = new NotificationEmailModel(member);
model.Email = Email;
model.Name = Name;
model.RedirectUrl = "http://example.com/" + member.UserName + "/calismalar";
UIMailingManager.Instance.SendNotification(model);
if(UIMailingManager.Instance.SendNotification(model).Success)
{
isSent = true;
//comment
}
}
catch(Exception ex)
{
Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
}
return Json(isSent, JsonRequestBehavior.AllowGet);
下面是我的调用者代码,它使用 WebClient.UploadValues 通过使用“POST”方法将数据发布到上述操作。
using (var wb = new WebClient())
{
var data = new NameValueCollection();
data["MemberId"] = item.Member.Id.ToString();
data["Email"] = item.Member.Email;
data["Name"] = item.Member.Name;
data["RedirectUrl"] = "http://example.com/" + item.Member.UserName + "/calismalar";
var resp = wb.UploadValues("http://example.com/ServiceMail/SendNotification", "POST", data);
}
但这给出了一个错误,根本没有详细的解释。会是什么原因?
更新:Elmah 的错误信息:
System.Web.HttpException (0x80004005):公共操作方法 在控制器上找不到“SendNotification” 'HintKumasi.UI.Controllers.ServiceMailController'。在 System.Web.Mvc.Controller.HandleUnknownAction(String actionName) 在 System.Web.Mvc.Controller.b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) 在 System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)1.CallEndDelegate(IAsyncResult asyncResult) 在 System.Web.Mvc.MvcHandler.b__5(IAsyncResult asyncResult, ProcessRequestState innerState) 在 System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid` 1.CallEndDelegate(IAsyncResult
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoidasyncResult) 在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 在 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤, Boolean & completedSynchronously)
【问题讨论】:
-
您能否发布您收到的错误消息,ELMAH 说什么