我有asp.net web MVC4,它可以在邮递员本地主机上测试出来,并且工作正常。当我在服务器上发布它并检查邮递员时,我看到这个请求的URL长度超过了配置的maxUrlLength值,我将数据数量减少到一个!但还是同样的错误
我的班级:
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 }
);web配置:
<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>发布于 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。
https://stackoverflow.com/questions/58610728
复制相似问题