Reputation: 236
I've made MVC project and published it to Azure . in the IIS local server it works fine, but on Azure when it's routing to delete it does not route to the delete view and stop in Delete action and this appears instead :
and when I open the console of the browser this problem message appears :
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
this is the code :
the 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);
}
}
the Model :
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; }
}
Index 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 />
}
delete 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>
What's the problem please? And how can I fix it?
Upvotes: 3
Views: 6210
Reputation: 236
after I've followed the End-to-end transaction details I've found this problem :
A claim of type 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier' or 'http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider' was not present on the provided ClaimsIdentity. To enable anti-forgery token support with claims-based authentication, please verify that the configured claims provider is providing both of these claims on the ClaimsIdentity instances it generates. If the configured claims provider instead uses a different claim type as a unique identifier, it can be configured by setting the static property AntiForgeryConfig.UniqueClaimTypeIdentifier.
and I've solved it by adding this code line to Global.asax
AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;
using these :
using System.Security.Claims;
using System.Web.Helpers;
Upvotes: 1
Reputation: 61
The code 500 means that the app didn't found the source your looking for it can be the controller or action name is wrong or parameters missing or wrong i think you should change your ActionLink to this:
@Html.ActionLink("Delete","Delete","Groups",new { id = item.ID, groupname = item.Name, useremail = item.UserEmail[i] })
Upvotes: 1