首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在iis上发布api后,仅4行数据的URL长度超过了配置的maxUrlLength值。

在iis上发布api后,仅4行数据的URL长度超过了配置的maxUrlLength值。
EN

Stack Overflow用户
提问于 2019-10-29 15:37:30
回答 1查看 675关注 0票数 1

我有asp.net web MVC4,它可以在邮递员本地主机上测试出来,并且工作正常。当我在服务器上发布它并检查邮递员时,我看到这个请求的URL长度超过了配置的maxUrlLength值,我将数据数量减少到一个!但还是同样的错误

我的班级:

代码语言:javascript
复制
  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();

这是我的webApiConfig:

代码语言:javascript
复制
  config.Filters.Add(new BasicAuthenticationAttribute());


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

web配置:

代码语言:javascript
复制
    <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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-29 16:13:49

更新maxUrlLength属性在您的web.config:https://learn.microsoft.com/en-us/dotnet/api/system.web.configuration.httpruntimesection.maxurllength?view=netframework-4.8

尝试使用允许的最大值,即209715。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58610728

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档