Vmware + CentOS 7 + Jexus 5.8.3 独立版部署 + .Net Core

2019-01-02 20:58发布

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中时,数据库老是超时。没有数据库操作的页面,都正常。

1条回答
裙下三千臣
2楼-- · 2019-01-02 21:28

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

查看更多
登录 后发表回答