1
17/11/2016
I have an application that is mounting the following URL
www.meusite.com.br/controller/action/id
However, I need the ID
not displayed in the URL, but let it live on back-end
, because it’s a request screen, and I wouldn’t want to leave the id
of the request displayed in the URL.
Each order is tied to a store, and I have a validation so that only the store logins xpto
access the store’s orders xpto
, and not ordered from other shops.
I just need to disappear with the URL ID and leave it alive in the system, but it’s a bit complicated to find a solution. I’ve read several articles, but nothing clarifying.
Anyone who can help, I really appreciate.
18/11/2016
Marllon Nasser, I followed your idea and did it this way:
@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 by passing the request id, only on 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");
}
}
Just don’t open it. How can I please make any suggestions?
utilize
post
instead ofget
.– Marllon Nasser