title: Query parameter routing with asp .net core
body: <p>I'd like to use url query parameter instead of path parameter using .net core API.</p>
  
  <p>controller</p>
  
  <pre><code>[Route("api/[controller]/[action]")]
  public class TranslateController : Controller
  {
      [HttpGet("{languageCode}")]
      public IActionResult GetAllTranslations(string languageCode)
      {
          return languageCode;
      }
  }
  </code></pre>
  
  <p>startup.cs is using only default settings</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      // Add framework services.
      services.AddMvc()
              .AddJsonOptions(jsonOptions =&gt;
              {
                  jsonOptions.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
                  jsonOptions.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                  jsonOptions.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
              });
  
      services.AddLogging();
      services.AddSingleton&lt;IConfiguration&gt;(Configuration);
  
      services.AddSwaggerGen(c =&gt;
      {
          c.SingleApiVersion(new Info
          {
              Version = "v1",
              Title = "Translate API",
              Description = "bla bla bla description",
              TermsOfService = "bla bla bla terms of service"
          });
      });
  }
  
  // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  {
      loggerFactory.AddConsole(Configuration.GetSection("Logging"));
      loggerFactory.AddDebug();
  
      app.UseMvc();
  
      app.UseSwagger();
      app.UseSwaggerUi();
  }
  </code></pre>
  
  <p>my swagger request looks like this
  <a href="https://i.stack.imgur.com/ZZE2H.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZZE2H.png" alt="enter image description here"></a></p>
  
  <p>my postman request is here
  <a href="https://i.stack.imgur.com/gvJZ7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gvJZ7.png" alt="enter image description here"></a></p>
  
  <p>I would like to change my GetAllTranslations to accept query parameter instead of path parameter but when I change my postman query to </p>
  
  <pre><code>http://localhost:42677/api/Translate/GetAllTranslations?languageCode=en
  </code></pre>
  
  <p>I will get error 404 Not found so obviously my controller path is not set correctly, but I cannot find out how to do this... Any Ideas?</p>
  
  <p>I have tried removing the [HttpGet("{languageCode}")] attribute, but I keep getting null parameter instead of the value. </p>