17/11/2016
I have an application that is building the following URL
www.mysite.com/controller/action/id
However, I need the ID
not to be displayed in the URL, but to leave it alive in back-end
, because it is a requests screen, and I would not like to leave the id
of the request running in the URL.
Each order is tied to a store, and I have a validation so that only the logins of the xpto
store access requests from the xpto
store, not requests from other stores.
I just need to get rid of the URL ID and make it live on the system, but it's kind of complicated to find a solution. I have read several articles, but nothing enlightening.
Who can help, I thank you.
18/11/2016
Marllon Nasser, I followed your idea and did it as follows:
@this.Hidden("IdPedido").Value(item.Id)
<a class="btn btn-primary btn-xs btn-visualizar" target="_blank" data-toggle="tooltip" title="Visualizar">
<i class="fa fa-eye">< /i>
</a>
$(function() {
$(".btn-visualizar").click(function() {
var pedido = $("#IdPedido").val();
$.post("@(Url.Action(MVC.Painel.Pedidos.Visualizar()))", {
id: pedido
})
});
});
It goes to the controller passing the request id, but in my controller I need to open another view called "requests".
[HttpPost]
public virtual ActionResult Visualizar(int id)
{
var user = TUser.FindByUserName(this.User.Identity.Name);
var pedido = TOrder.Load(id);
var xpto = pedido.Franchise.Name;
if (user.Franchise == null || user.Franchise.Id == pedido.Franchise.Id)
{
//return View(pedido);
return RedirectToAction("Visualizar", pedido);
}
else
{
TempData["Error"] = "Pedido não pertence a esta loja";
return RedirectToAction("Index");
}
}
But it's not opening. How can I make any suggestions?