首页 新闻 赞助 找找看

.net core 1.0 发布到centos7.1 导致控制器方法访问出现404 怎么解决?

0
[已解决问题] 解决于 2016-09-29 17:42

这是控制器的一个方法

public string GetProductList(int page, int rows, string number, string pname, string categoryid, string propertyid, string brandid, string sprice, string eprice, string isonsale, string storageID)

http://***:5005/Product/GetProductList?page=1&rows=15

这样访问在本地环境是可以的。

但是在centos7.1 报错:

复制代码
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://***:5005/Product/GetProductList?page=1&rows=15
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
      Executing action method Web.Controllers.ProductController.GetProductList (Web) with arguments (1, 15, , , , , , , , , ) - ModelState is Valid
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
      An unhandled exception has occurred: Cannot perform runtime binding on a null reference
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference
   at CallSite.Target(Closure , CallSite , Object )
   at BLL.ProductBackupBLL.GetPage2(String extsql, String sortsql, Int32 pageIndex, Int32 pageCount, Int32& totalPages, Int32& totalItems)
   at Web.Controllers.ProductController.GetProductList(Int32 page, Int32 rows, String number, String pname, String categoryid, String propertyid, String brandid, String sprice, String eprice, String isonsale, String storageID)
   at lambda_method(Closure , Object , Object[] )
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionFilterAsync>d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeAsync>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Session.SessionMiddleware.<Invoke>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Session.SessionMiddleware.<Invoke>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
复制代码
问题补充:

Executing action method Web.Controllers.ProductController.GetProductList (Web) with arguments (1, 15, , , , , , , , , ) - ModelState is Valid

意思是说我没有提供后面的参数?找不到?

本地环境测试的时候程序会给没有传参的变量一个默认值。

Qingben的主页 Qingben | 初学一级 | 园豆:184
提问于:2016-09-29 16:20
< >
分享
最佳答案
0

这个明显是异常了.代码在

 at CallSite.Target(Closure , CallSite , Object )
   at BLL.ProductBackupBLL.GetPage2(String extsql, String sortsql, Int32 pageIndex, Int32 pageCount, Int32& totalPages, Int32& totalItems)

在这方法里.看看吧.是哪行抛的.或者看看getpage2是个啥东西

奖励园豆:5
吴瑞祥 | 高人七级 |园豆:29449 | 2016-09-29 17:21

getpage2 里面用了dynamic 类型,导致空引用。
但是本地环境运行屁事没有,日了狗了。

Qingben | 园豆:184 (初学一级) | 2016-09-29 17:42
其他回答(3)
0

从出错信息看应该是数据库访问部分的问题

dudu | 园豆:31075 (高人七级) | 2016-09-29 16:25

我本地访问是没有问题的。数据库访问部分有问题我有日志记录的,但是目前没有日志。http的状态是404

支持(0) 反对(0) Qingben | 园豆:184 (初学一级) | 2016-09-29 16:28
0

提示有 空引用

CodeHsu | 园豆:5468 (大侠五级) | 2016-09-29 16:28

你这翻译的不错。

支持(0) 反对(0) Qingben | 园豆:184 (初学一级) | 2016-09-29 16:29
0

我特他妈的局部404,无解。
我有2台服务器(Linux CentOS)。
本地跑起来没问题。发布到第一台服务器也是没问题(64位的)(正常访问User/Index正常返回页面。)。
但是第二台服务器(64位的)就有问题:访问(/User/Index)返回404找不到该页面。但是我访问其他的控制器比如(Movie/Index等等)都能正常返回。
重新发布了好多次都是有这个问题。好奇怪。
部署是使用Nginx做了反向代理的。
这种问题如何百度或者什么思路
发布方式都是“可移植”。

CaptainBruke | 园豆:202 (菜鸟二级) | 2019-12-12 17:07
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册