首页 新闻 会员 周边

Vmware + CentOS 7 + Jexus 5.8.3 独立版部署 + .Net Core 2.1 + Dapper 连接数据库超时

0
悬赏园豆:5 [已解决问题] 解决于 2018-11-25 19:04

Controller代码:

public SiteConfig config;
public static IDbConnection conn;
public HomeController(IOptionsSnapshot<SiteConfig> option)
{
config = option.Value;
conn = new SqlConnection(config.value);
}

    public IActionResult Index()
    {
        using (conn)
        {
            ContentModel m = new ContentModel
            {
                title = "这里是标题1",
                content = "这里是内容2",
                adddate = DateTime.Now
            };
            string sql = "insert into content(title,content,adddate) values(@title,@content,@adddate)";
            int i = conn.Execute(sql.ToString(), new { title = m.title, content = m.content, adddate = m.adddate });
            ViewBag.a = i.ToString();
            return View();
        }
    
    }

appsettings.json 代码:

{
"SiteConfig": {
"name": "test",
"value": "Data Source=192.168.11.209; Initial Catalog=MyBlog;User ID=sa;Password=sa"
},
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}

在vs中都正常,但是部署到jexus中时,数据库老是超时。没有数据库操作的页面,都正常。

DZCMS的主页 DZCMS | 初学一级 | 园豆:5
提问于:2018-11-21 09:27
< >
分享
最佳答案
0

你虚拟机里面,网络通畅吗,或者说,能访问到数据库服务器的ip吗

收获园豆:5
顾星河 | 大侠五级 |园豆:7173 | 2018-11-21 11:46
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册