Asp.net mvc 4 getting The length of the URL for this request exceeds the configured maxUrlLength value for only 4 lines of data after publish api on iis

Asp.net mvc 4 getting The length of the URL for this request exceeds the configured maxUrlLength value for only 4 lines of data after publish api on iis,asp.net-mvc-4,asp.net-web-api,Asp.net Mvc 4,Asp.net Web Api,I have asp.net web api MVC4 which test it out on POSTMAN local host and it works fine,when i publish it on server and check on Postman i see The length of the URL for this request exceeds the configured maxUrlLength value,i reduced the number of data to one! but still the same error my class: public IEnumerable<myStat10> Get(string id, string dttimeFrom, string dttimeTo) { string format = "ddMMyyyy"; DateTime fromdate = DateTime.ParseExact(dttimeFrom, format, Cul

I have asp.net web api MVC4 which test it out on POSTMAN local host and it works fine,when i publish it on server and check on Postman i see The length of the URL for this request exceeds the configured maxUrlLength value,i reduced the number of data to one! but still the same error

my class:

  public IEnumerable<myStat10> Get(string id, string dttimeFrom, string dttimeTo)

    {

        string format = "ddMMyyyy";
        DateTime fromdate = DateTime.ParseExact(dttimeFrom, format, CultureInfo.InvariantCulture);
        DateTime todate = DateTime.ParseExact(dttimeTo, format, CultureInfo.InvariantCulture);
        IPAddress turip = IPAddress.Parse(id);

        var rslt = (from m in _context.stat10

                    where m.m_turbine_id ==id && m.m_time_stamp >= fromdate && m.m_time_stamp <= todate
                    select new myStat10

                    {
                          m_time_stamp=m.m_time_stamp,
                          m_turbine_id=m.m_turbine_id,                  
                          m_wind_speed=m.m_wind_speed, 
                          m_rpm =m.m_rpm,
                          m_power=m.m_power, 
                          m_t_blade_1=m.m_t_blade_1, 
                          m_t_blade_2=m.m_t_blade_2, 

                    }).Take(1).toList();

its my webApiConfig:

  config.Filters.Add(new BasicAuthenticationAttribute());


        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );

web config:

    <httpRuntime maxUrlLength="209715" />
    <customErrors mode="Off" />
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.7.1" />
    <authentication mode="None" />
    <pages>
    <namespaces>
    <add namespace="System.Web.Helpers" />
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Optimization" />
    <add namespace="System.Web.Routing" />
    <add namespace="System.Web.WebPages" />
  </namespaces>
</pages>

#1

Update the maxUrlLength property in your web.config: https://docs.microsoft.com/en-us/dotnet/api/system.web.configuration.httpruntimesection.maxurllength?view=netframework-4.8

Try using the max value allowed which is 209715.


#2

Have you updated the maxUrlLength property in your web.config?

#3

Can we see the httpruntime section of your web.config?

#4

updated my question with your suggestion,bust when i change to the 209715 i get internal error 500

#5

You must add it to your <system.web> section.