We have moved to GitHub Issues
You are viewing the read-only archive of Umbraco's issue tracker. To create new issues, please head over to GitHub Issues.
Make sure to read the blog posts announcing the move for more information.
Created by Jesper Hauge 05 Nov 2013, 18:45:41 Updated by Sebastiaan Janssen 05 Jun 2015, 16:28:23
Clicked the rightmost starterkit in last step on install running install procedure through IISExpress on VS 2012. Got YSOD content inline on install page. Now gets full blown YSOD when trying to load both root and /umbraco in site.
Getting:
Microsoft (R) Visual C# Compiler version 4.0.30319.33440
for Microsoft (R) .NET Framework 4.5 Copyright (C) Microsoft Corporation. All rights reserved.
c:\Projects\UmbTest\U7RC\U7RC\App_Code\UmbContactController.cs(16,16): error CS0246: The type or namespace name 'HttpResponseMessage' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
14: { 15: // POST umbraco/api/umbcontact/post 16: public HttpResponseMessage Post([FromBody]UmbContactMail message) 17: { 18: // Return errors if the model validation fails
Complete Code:
1: using System;
2: using System.ComponentModel.DataAnnotations;
3: using System.Linq;
4: using System.Net;
5: using System.Net.Http;
6: using System.Web.Http;
7: using Umbraco.Core.Logging;
8: using Umbraco.Web;
9: using Umbraco.Web.WebApi;
10:
11: namespace Overflow.Controllers
12: {
13: public class UmbContactController : UmbracoApiController
14: {
15: // POST umbraco/api/umbcontact/post
16: public HttpResponseMessage Post([FromBody]UmbContactMail message)
17: {
18: // Return errors if the model validation fails
19: // The model defines validations for empty or invalid email addresses
20: // See the UmbContactMail class below
21: if (ModelState.IsValid == false)
22: return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState.First().Value.Errors.First().ErrorMessage);
23:
24: // In order to allow editors to configure the email address where contact
25: // mails will be sent, we require that to be set in a property with the
26: // alias umbEmailTo - This property needs to be sent into this API call
27: var umbraco = new UmbracoHelper(UmbracoContext);
28: var content = umbraco.TypedContent(message.SettingsNodeId);
29:
30: if (content == null)
31: return Request.CreateErrorResponse(HttpStatusCode.BadRequest,
32: "Please provide a valid node Id on which the umbEmailTo property is defined.");
33:
34: var mailTo = content.GetPropertyValue
36: if (string.IsNullOrWhiteSpace(mailTo))
37: return Request.CreateErrorResponse(HttpStatusCode.BadRequest,
38: string.Format("The umbEmailTo property on node {0} (Id {1}) does not exists or has not been filled in.",
39: content.Name, content.Id));
40:
41: // If we have a valid email address to send the email to, we can try to
42: // send it. If the is an error, it's most likely caused by a wrong SMTP configuration
43: return TrySendMail(message, mailTo)
44: ? new HttpResponseMessage(HttpStatusCode.OK)
45: : Request.CreateErrorResponse(HttpStatusCode.ServiceUnavailable,
46: "Could not send email. Make sure the server settings in the mailSettings section of the Web.config file are configured correctly. For a detailed error, check /App_Data/Logs/UmbracoTraceLog.txt.");
47: }
48:
49: private static bool TrySendMail(UmbContactMail message, string mailTo)
50: {
51: try
52: {
53: var content = string.Empty;
54: content += string.Format("You have a new contact mail from {0}", string.IsNullOrWhiteSpace(message.Name) ? "[no name given]" : message.Name);
55: content += "\r\n";
56: content += "They said:";
57: content += "\r\n";
58: content += string.Format("{0}", string.IsNullOrWhiteSpace(message.Message) ? "[no message entered]" : message.Message);
59:
60: var mailFrom = new System.Net.Mail.MailAddress(message.Email, message.Name);
61:
62: var mailMsg = new System.Net.Mail.MailMessage
63: {
64: From = mailFrom,
65: Subject = "Contact mail",
66: Body = content,
67: IsBodyHtml = false
68: };
69:
70: mailMsg.To.Add(new System.Net.Mail.MailAddress(mailTo));
71: mailMsg.ReplyToList.Add(mailFrom);
72:
73: var smtpClient = new System.Net.Mail.SmtpClient();
74: smtpClient.Send(mailMsg);
75:
76: return true;
77: }
78: catch (Exception ex)
79: {
80: LogHelper.Error
83: return false;
84: }
85:
86: public class UmbContactMail
87: {
88: public int SettingsNodeId { get; set; }
89:
90: public string Name { get; set; }
91:
92: [Required(ErrorMessage = "Please provide a valid e-mail address")]
93: [RegularExpression(@"[a-zA-Z0-9!#%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#%&'*+/=?^_`{|}
97: public string Message { get; set; }
98: }
99: }
100: }
101:
NuGet install I presume? We'll have to include System.Net.Http in the final release.
It is a NuGet install, but System.Net.Http is already referenced in the project, only System.Net.Http.Formatting.dll is in the bin-folder after build though. VS isn't reporting any errors on the reference.
Just went and downloaded normal zip file from Our which includes System.Net.Http.dll and System.Net.Http.Extensions.dll, copied those to the bin folder and now everything is running smoothly.
@Jesper exactly, I saw this same problem while making the starter kit, but I forgot to check if the nuget package included them. Will fix for the final release, thanks!
is this fixed?
I'll update as usual when it is fixed (this weekend).
Fixed in rev 17db60c34a55ba4df4e879481b1cd77e25f48e3c. Would appreciate a test @Jesper, latest build (162) is up in the MyGet feed - https://www.myget.org/F/umbraconightly/
Priority: Normal
Type: Bug
State: Fixed
Assignee:
Difficulty: Normal
Category:
Backwards Compatible: True
Fix Submitted:
Affected versions: 7.0.0
Due in version: 7.0.0
Sprint:
Story Points:
Cycle: