Microsoft.Extensions.Options.OptionsValidationException
HResult=0x80131500
Message=Configuration entry Umbraco:CMS:Global:Smtp contains one or more invalid values. A valid From email address is required.
Source=Microsoft.Extensions.Options
StackTrace:
at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
at Microsoft.Extensions.Options.UnnamedOptionsManager`1.get_Value()
at Umbraco.Cms.Infrastructure.DependencyInjection.UmbracoBuilderExtensions.<>c.<AddMainDom>b__4_0(IServiceProvider factory)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Umbraco.Extensions.WebApplicationExtensions.<BootUmbracoAsync>d__0.MoveNext()
at Program.<<Main>$>d__0.MoveNext() in C:\Users\post\Desktop\Yggdrasila Ny\Yggdrasila\Program.cs:line 20
Sorry to hear you are having a hard time, but the message in the error says
Configuration entry Umbraco:CMS:Global:Smtp contains one or more invalid values. A valid From email address is required
Take a look at your JSON you posted above and see if you can spot the typo mistake, your property for the from email address for SMTP is set as rom and not from
The fix is to fix the typo and it should be happier again
Now it fails on line 4 and 28 Main.cshtml. I realy dont know whats going on, I write the codes the same as Paul Seal, and it crash. I try to write the code on more time, and rebuild. Then it fails on another place
Can we get the error as well to help diagnose the issue, as just a line number without the error or stack trace message from .NET its hard to know what is up.
No errors in VS, but I have 3 messages:
IDE0290 Line 28 ContactSurfaceController
IDE0046 Line 18 PublishedContentExtensions
IDE0046 Line 28 PublishedContentExtensions
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Logging;
using Umbraco.Cms.Core.Mail;
using Umbraco.Cms.Core.Models.Email;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Web.Website.Controllers;
using Yggdrasila.Configuration;
using Yggdrasila.Models.ViewModels;
namespace Yggdrasila.Controllers.Surface;
public class ContactSurfaceController : SurfaceController
{
private readonly IEmailSender _emailSender;
private readonly ILogger<ContactSurfaceController> _logger;
private readonly YggdrasilaConfig _yggdrasilaConfig;
public ContactSurfaceController(
IUmbracoContextAccessor umbracoContextAccessor,
IUmbracoDatabaseFactory databaseFactory,
ServiceContext services,
AppCaches appCaches,
IProfilingLogger profilingLogger,
IPublishedUrlProvider publishedUrlProvider,
IEmailSender emailSender,
ILogger<ContactSurfaceController> logger,
IOptions<YggdrasilaConfig> yggdrasilaConfig) : base(umbracoContextAccessor, databaseFactory, services, appCaches, profilingLogger, publishedUrlProvider)
{
_emailSender = emailSender;
_logger = logger;
_yggdrasilaConfig = yggdrasilaConfig.Value;
}
public async Task<IActionResult> Submit(ContactViewModel model)
{
if (!ModelState.IsValid)
{
return CurrentUmbracoPage();
}
try
{
var subject = string.Format("Enquiry from: {0} - {1}", model.Name, model.Email);
EmailMessage message = new(_yggdrasilaConfig?.EmailSettings?.From,
_yggdrasilaConfig?.EmailSettings?.To, subject, model.Message, false);
await _emailSender.SendAsync(message, emailType: "Contact");
TempData["ContactSuccess"] = true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Error submitting contact form");
TempData["ContactSuccess"] = false;
}
return RedirectToCurrentUmbracoPage();
}
}
<!-- About Section-->
<section class="page-section bg-primary text-white mb-0" id="about">
<div class="container">
<!-- About Section Heading-->
<h2 class="page-section-heading text-center text-uppercase text-white">About</h2>
<!-- Icon Divider-->
<div class="divider-custom divider-light">
<div class="divider-custom-line"></div>
<div class="divider-custom-icon"><i class="fas fa-star"></i></div>
<div class="divider-custom-line"></div>
</div>
<!-- About Section Content-->
<div class="row">
<div class="col-lg-4 ms-auto"><p class="lead">Freelancer is a free bootstrap theme created by Start Bootstrap. The download includes the complete source files including HTML, CSS, and JavaScript as well as optional SASS stylesheets for easy customization.</p></div>
<div class="col-lg-4 me-auto"><p class="lead">You can create your own custom avatar for the masthead, change the icon in the dividers, and add your email address to the contact form to make it fully functional!</p></div>
</div>
<!-- About Section Button-->
<div class="text-center mt-4">
<a class="btn btn-xl btn-outline-light" href="https://startbootstrap.com/theme/freelancer/">
<i class="fas fa-download me-2"></i>
Free Download!
</a>
</div>
</div>
</section>
using System.ComponentModel.DataAnnotations;
using Yggdrasila.Validation;
namespace Yggdrasila.Models.ViewModels;
public class ContactViewModel
{
[Display(Name = "Full name")]
[Required(ErrorMessage = "You must enter your name")]
public string? Name { get; set; }
[Display(Name = "Email address")]
[EmailAddress(ErrorMessage = "You must enter a valid email address")]
[Required(ErrorMessage = "You must enter your email address")]
public string? Email { get; set; }
[Display(Name = "Phone number")]
public string? Phone { get; set; }
[Display(Name = "Message")]
[Required(ErrorMessage = "You must enter your message")]
public string? Message { get; set; }
[Display(Name = "Yes, I give permission to store and process my data")]
[Required(ErrorMessage = "You must give consent to us storing your details before you can send us a message")]
[MustBeTrue(ErrorMessage = "You must give consent to us storing your details before you can send us a message")]
public bool Consent { get; set; }
}
Are you currently in Paul Seals YouTube series trying to implement a contact form?
Then I would refer back to his video or tutorial in case you have missed a step.
This file you have shared of ContactViewModel, would be used/consumed by other parts of the codebase and that is what I am interested in knowing.
With Visual Studio you can right click the word ContactViewModel in the code on the line that reads and use the option Find All References
Also as you seem to be following along with Pauls tutorial that you grab a copy of the finished repository and working codebase to see if that runs and works for you.
If so then you can play the game of spot the difference between your codebase and the finished final result.
Now im pretty tired of this fault. Can someone fix this on my computer? Ive tried everything, and nothing works. And I dont want to start on Episode.1 with new projekt.
Sorry to hear you are having a hard time with this.
I suggest you unzipping the source code that I have linked from Paul Seals GitHub repo and see if you can run that without any issues and see what differs from your code and his.
As the past errors that we have helped figure out, it seems to be a small typo most of the times. Such as a missing closing } in JSON files or a semicolon in C# files.
So I would thoroughly check and play spot the difference.
There are visual tools out there that can be used to compare two files side by side, which may help you spot what may or may not be missing.