1. Scott Anderson
  2. ActionMailer.Net
  3. Issues
Issue #42 resolved

Problem with areas still persists. The provided solution was incorrect.

Anonymous created an issue

Area name should be determined from current http request's routedata->DataTokens["area"] rather from type's namespace.

If controller's namespace doesn't contain ".Areas." part this check will fail. This solution also forces developer to include ".Areas." namespace into his namespace structure without any real sense.

Comments (3)

  1. Anonymous

    A suggested solution:

    		public override EmailResult Email(string viewName, object model = null, string masterName = null)
    			if (viewName == null)
    				throw new ArgumentNullException("viewName");
    			var emailResult = new EmailResult(this, MailSender, this.GenerateMail(), viewName, masterName, MessageEncoding);
    			ViewData.Model = model;
    			emailResult.ViewData = ViewData;
    			var routeData = new RouteData();
    			routeData.DataTokens["area"] = HttpContextBase.Request.RequestContext.RouteData.DataTokens["area"];
    			routeData.Values["controller"] = GetType().Name.Replace("Controller", string.Empty);
    			routeData.Values["action"] = viewName;
    			ControllerContext = new ControllerContext(new RequestContext(HttpContextBase, routeData), this);
    			return emailResult;
  2. Log in to comment