ASP.NET MVC应用程序可在调试中工作,但使用Plesk和GoDaddy发布时则无法工作

问题描述 投票:0回答:1

我有一个MVC应用程序,可以在调试模式和测试中完美运行,但是在我使用ftp发布到godaddy之后,该网站打开并在首页和登录页面之间切换时可以正常工作。如果我尝试登录时遇到错误,或者尝试使用主页上的搜索框,也会遇到错误。这是屏幕截图:Error

[我登录后或基本上没有登录,但没有'mydomain'.com/Home/Index/出现此错误,如果尝试'mydomain'.com/Home/Search'mydomain'.com/Search/Index任何其他控制器或操作,则会得到此错误。我尝试了一切可能是什么原因?例如HomeController / Search:

public ActionResult Search(string search, string searchlast)
    {
        var doctors = from d in db.Doctors
                      select d;
        if (!String.IsNullOrEmpty(search) || !String.IsNullOrEmpty(searchlast))
        {
            doctors = doctors.Where(d => d.FirstName.Contains(search) && d.LastName.Contains(searchlast));
            return View(doctors.ToList());
        }
        return RedirectToAction("Index", "Home");
    }

这里是显示错误的Views / Home / Search:

@model IEnumerable<Systemz.Models.Check>
@{
    ViewBag.Title = "Search";
}

<div class="jumbotron">
    <h2>Check</h2>
    <h4>Check for availability.</h4>
</div>

@using (Html.BeginForm("Search", "Home", FormMethod.Post))
{
    <p>
        First Name: @Html.TextBox("search") Last Name: @Html.TextBox("searchlast")
        <input type="submit" value="Search" name="search" />
        <a asp-action="Search" asp-controller="Home"></a>
    </p>
}

<table class="table table-hover dataTable">
    <div class="row">
        <div class="col-md-4">
            <thead class="bd-dark white-text">
                <tr>
                    <th>
                        Title:
                    </th>
                    <th>
                        First Name:
                    </th>
                    <th>
                        Last Name:
                    </th>
                    <th>
                        Address:
                    </th>
                    <th>
                        Is Available?
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr>
                        <td>
                            @Html.DisplayFor(modelItem => item.Title)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.FirstName)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.LastName)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.Address)
                        </td>
                        <td>
                            @if (item.IsAvailable == true)
                            {<p><a class="btn btn-success"></a></p> }
                            else
                            { <p><a class="btn btn-danger"></a></p>}
                        </td>
                    </tr>
                }
            </tbody>
        </div>
    </div>
</table>
c# asp.net plesk
1个回答
0
投票

您必须上载数据库。 Godaddy托管服务器上没有(LocalDb)这样的东西。您还必须将数据库上传到Godaddy,找出到该位置的连接字符串,然后将其正确部署到您的站点。如果前面没有防火墙,您甚至可以从本地计算机测试到该数据库的连接。

编辑:仅上载数据库文件是不够的。您必须通过自己的工具来设置数据库,以便它可以正确地附加所有内容。

© www.soinside.com 2019 - 2024. All rights reserved.