gpt4 book ai didi

c# - 无法加载资源: the server responded with a status of 500 (Internal Server Error) Azure MVC

转载 作者:行者123 更新时间:2023-11-30 22:51:26 25 4
gpt4 key购买 nike

我已经制作了 MVC 项目并将其发布到 Azure 。在 IIS 本地服务器中它工作正常,但在 Azure 上,当它路由到删除时,它不会路由到删除 View 并停止在删除操作中,而是显示:

Text

当我打开浏览器的控制台时,会出现此问题消息:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

这是代码:

Controller :

  public class GroupsController : Controller
{
//the rest of the code
// GET: Groups
public ActionResult Index()
{
List<GroupsModels> groups = GetJsonFile();
return View(groups);
}
// GET: Groups/Delete/
[HttpGet]
public ActionResult Delete(int id,string groupname,string useremail)
{
GroupsModels temp = new GroupsModels
{
ID = id,
Name = groupname,
newuser = useremail
};
return View(temp);
}
}

型号:

public class GroupsModels
{
public GroupsModels()
{
this.UserEmail = new List<string>();
}
public int ID { get; set; }
public string Name { get; set; }
[EmailAddress(ErrorMessage = "Invalid Email Address")]
public string newuser { get; set; }
public List<string> UserEmail { get; set; }
}

索引 View :

@model IEnumerable<DashBoard.Models.GroupsModels>

@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Roles</h2>


@foreach (var item in Model)
{

<div class="row alert-success" style="text-align: center;font-size:large; padding:10px;">
<div class="col-sm">
<b> @Html.DisplayFor(modelItem => item.Name) |</b>
@Html.ActionLink("Add User", "Add", "Groups", new { GroupId = item.ID },null)

</div>

</div>

<div class="row border-bottom border ">
@for (int i = 0; i < item.UserEmail.Count(); ++i)
{

<div class="col-6 col-md-4 border">
<b> @Html.DisplayFor(modelItem => item.UserEmail[i])|</b>
@Html.ActionLink("Delete","Delete","Groups",new { id = item.ID, groupname = item.Name, useremail = item.UserEmail[i] },null)
</div>
if (i == 2)
{

<div class="w-100"></div>
}
}

</div>

<br />
}

删除 View :

  @model DashBoard.Models.GroupsModels

@{
ViewBag.Title = "Delete";
Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Delete</h2>

<h3>Are you sure you want to delete this?</h3>
<div>
<h4>GroupsModels</h4>
<hr />
<dl class="dl-horizontal">
<dt>
<b>Group Name</b>
</dt>

<dd>
@Html.DisplayFor(model => model.Name)
</dd>

<dt>
<B>User Email</B>
</dt>

<dd>
@Html.DisplayFor(model => model.newuser)
</dd>

</dl>

@using (Html.BeginForm()) {
@Html.AntiForgeryToken()

<div class="form-actions no-color">
<input type="submit" value="Delete" class="btn btn-default" /> |
@Html.ActionLink("Back to List", "Index")
</div>
}
</div>

请问有什么问题吗?我该如何解决它?

最佳答案

代码 500 意味着应用程序没有找到您要查找的源,可能是 Controller 或操作名称错误或参数丢失或错误,我认为您应该将 ActionLink 更改为:

@Html.ActionLink("Delete","Delete","Groups",new { id = item.ID, groupname = item.Name, useremail = item.UserEmail[i] })

关于c# - 无法加载资源: the server responded with a status of 500 (Internal Server Error) Azure MVC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59176827/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com