getting The length of the URL for this request exceeds the length of the configured maxUrlLength value for only 4 lines of data after publish api 在iis上
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 web api MVC4,它在 POSTMAN 本地主机上测试它并且工作正常,当我在服务器上发布它并检查 Postman 我看到 [= 的长度26=]对于这个请求超过了配置的maxUrlLength值,我将数据条数减为一条!但还是一样的错误
我的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();
这是我的 webApiConfig:
config.Filters.Add(new BasicAuthenticationAttribute());
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
网络配置:
<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>
更新您 web.config 中的 maxUrlLength 属性:https://docs.microsoft.com/en-us/dotnet/api/system.web.configuration.httpruntimesection.maxurllength?view=netframework-4.8
尝试使用允许的最大值 209715。
我有 asp.net web api MVC4,它在 POSTMAN 本地主机上测试它并且工作正常,当我在服务器上发布它并检查 Postman 我看到 [= 的长度26=]对于这个请求超过了配置的maxUrlLength值,我将数据条数减为一条!但还是一样的错误
我的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();
这是我的 webApiConfig:
config.Filters.Add(new BasicAuthenticationAttribute());
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
网络配置:
<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>
更新您 web.config 中的 maxUrlLength 属性:https://docs.microsoft.com/en-us/dotnet/api/system.web.configuration.httpruntimesection.maxurllength?view=netframework-4.8
尝试使用允许的最大值 209715。