title: No argument was given that corresponds to the required formal parameter 'htmlAttributes' of 'IHtmlHelper - DropDownListFor
body: <p>I am having an issue which I haven't resolved at this point and I can't really find any answers.
  The error that I am getting, when I try to construct the dropdown list is this:</p>
  <pre><code> No argument was given that corresponds to the required formal parameter 'htmlAttributes'
   of 'IHtmlHelper&lt;ContactUsPageModel&gt;.DropDownListFor&lt;TResult&gt;(Expression&lt;Func&lt;ContactUsPageModel, TResult&gt;&gt;, IEnumerable&lt;SelectListItem&gt;, string, object)'
  </code></pre>
  <p>The code in my razor View page ContactUs.cshtml has the next structure:</p>
  <pre><code>@Html.DropDownListFor(model =&gt; model.Provincia,  PoblacionesExtensions.ToSelectList(ViewBag.locations), new{@class=&quot;form-control form-control-login font-weight-bold&quot;, @style=&quot;padding:0&quot;} )  
  </code></pre>
  <p>Inside the View Task, I am utilizing the <code>GetCurrentLocation()</code>
  function which gets all the provinces that I need in order to display to my dropdown list.
  I pass all the locations to a ViewBag var.</p>
  <p>The code of my Controller is this:</p>
  <pre><code>    [AllowAnonymous]
      public async Task&lt;IActionResult&gt; ContactUs()
      {
          var data = new ContactUsPageModel();
          var user = await userSessionVars.GetCurrentUser();
          var locationsVar = await userSessionVars.GetCurrentLocation();
          ViewBag.locations = locationsVar;
  
  
          if (user != null)
          {
              data = new ContactUsPageModel()
              {
                  Name = $&quot;{user.Nombre} {user.Ape1} {user.Ape2}&quot;,
                  Phone = user.UserName,
                  Email = user.Email,
              };
          }
  
          return View(data);
      }  
  </code></pre>
  <p>This task comes from my Helper. It is connected to one of the services of the Entity and gets all the locations that I need. It makes the request, receives the JSON and then deseriazes it:</p>
  <pre><code>   public async Task&lt;List&lt;string&gt;&gt; GetCurrentLocation(){
          var ConsultaLocalidadesEsp = await ServiceEntityHub.ConsultaLocalidadesEsp();
          var locations =  JsonConvert.DeserializeObject&lt;List&lt;PoblacionDto&gt;&gt;(ConsultaLocalidadesEsp);
          return  locations.Select(x =&gt; x.provincia).ToList();
      }
  </code></pre>
  <p>At last, I am constructing and returning the SelectList through another Helper that I made. It is located inside the /Helper/ directory. I return it to the dropdown list html element, inside my View razor page which I have pointed out at the very top of the question.</p>
  <pre><code>using Microsoft.AspNetCore.Mvc.Rendering;
  using System.Collections.Generic;
  using System.Linq;
  
  namespace Asistencia.Helper
  {
      public static class PoblacionesExtensions
      {
  
          public static SelectList ToSelectList(this List&lt;string&gt; poblaciones )
          {
              if(!poblaciones.Contains(&quot;Selecciona tu provincia&quot;))
              {
                  poblaciones.Add(&quot;Selecciona tu provincia&quot;);
              }
  
              return new SelectList(poblaciones, &quot;Selecciona tu provincia&quot;);
  
          }
  
      }
  }
  </code></pre>