I have a Telerik grid in which I am using client templates for edit/delete actions for each record. So for the edit/delete action I need to pass the id of that record along with the URL, here in this case I am afraid about some security issues. I am looking for a way to hide the query string parameter here to overcome this issues.
I am aware about encryption of parameter and currently I am using that. But i want to completely hide the query string parameter. I can't use session/ViewBag here since I can't set the session value for each record at the time of button click and access it in controller.
Any help is appreciated. Thanks in advance. my Controller and View codes are the following
View
@model IEnumerable<Data.Models.MyViewModel>
@{
Volunteer.Data.User currentUser = (Data.User)Session["CurrentUser"];
}
<div id="myDivId">
<p style="clear:none;">
@Html.ActionLink("Add", "Create", "MyController", new { area = "", ID = ViewBag.MyDataID }, new { @class = "aMyClass" })
</p>
@{
Html.Telerik().Grid<MyViewModel>().Name("MyGrid")
.Columns(col =>
{
col.Bound(c => c.FirstName).Width("120px");
col.Bound(c => c.LastName).Width("80px");
col.Bound(c => c.Designation).Width("80px");
col.Bound(c => c.Company).Width("80px");
col.Bound(c => c.Married).Filterable(false).ClientTemplate(
"<input type='checkbox'" + "<#= Married?\"checked\":\"\" #>" + " OnClick='return false' />"
).Width("40px");
if (currentUser.AdminRole == true || currentUser.Manager == true || currentUser.StaffRole == true)
{
col.Bound(c => c.EmployeeID).Sortable(false).ClientTemplate(
"<a href='" + Url.Content("~/MyController/Edit/") + "<#= EmployeeID #>' title='Edit Employee Details' class='edit'>Edit</a>" +
"<a href='" + Url.Content("~/MyController/Delete/") + "<#= EmployeeID #>' title='Delete Employee Details' class='delete'>Delete</a>"
).Title("Action").Width("75px");
}
else
{
col.Bound(c => c.EmployeeID).Sortable(false).ClientTemplate(
"<a href='" + Url.Content("~/MyController/Details/") + "<#= EmployeeID #>' title='Associated Party Details' class='details'>Details</a>"
).Title("Action").Width("75px");
}
})
.DataBinding(dataBinding => dataBinding.Ajax().Select("_GetEmployeeList", "MyController", new { id = "MyDataID" }))
.Pageable()
.Sortable()
.Render();
}
</div>
Controller
public ActionResult Edit(int id)//Want to pass this id without using Query string parameter
{
User user = (User)Session["CurrentUser"];
Employee employee = db.Employees.Single(c => c.EmployeeID == id);
//some code
return View(employee);
}
[HttpPost]
public ActionResult Edit(Employee employee)
{
User user = (User)Session["CurrentUser"];
if (ModelState.IsValid)
{
db.Employees.Attach(employee);
db.ObjectStateManager.ChangeObjectState(Employees, EntityState.Modified);
db.SaveChanges();
return RedirectToAction("Index");
}
Employee employee = db.Employees.Single(c => c.EmployeeID == id);
//some code
return View(employee);
}