So, we have a site that when passing the code of a user, it shows the location of the same.
URL example:
http://npaa1215.example.com/gisb_prod/integration/coordUser.aspx?codUser=30071665&zoom=15
In the URL we can pass the parameter codUser
.
In my application I have these codes and would like to insert in the field codUser
In the example the site pointing to user codUser=30071665
This is my Barcoviewmodel
[Key]
public Guid Id { get; set; }
[Required(ErrorMessage = "Campo Obrigatório")]
public string Nome { get; set; }
[Required(ErrorMessage = "Campo Obrigatório")]
public bool Ativo { get; set; }
[Display(Name = "Registro SAP")]
[Required(ErrorMessage = "Campo Obrigatório")]
public int SapId { get; set; }
[Display(Name = "Tancagem Água")]
[Required(ErrorMessage = "Campo Obrigatório")]
public int CapacidadeAgua { get; set; }
[Display(Name = "Tancagem óleo")]
[Required(ErrorMessage = "Campo Obrigatório")]
public int CapacidadeOleo { get; set; }
[Required(ErrorMessage = "Campo Obrigatório")]
public int Velocidade { get; set; }
[Required(ErrorMessage = "Preencha o campo E-mail")]
[MaxLength(100, ErrorMessage = "Máximo {0} caracteres")]
[EmailAddress(ErrorMessage = "Preencha um E-mail válido")]
[Display(Name ="E-mail")]
public string Email { get; set; }
And in my controler I thought about doing something like this:
string url = http://npaa1215.example.com/gisb_prod/integration/coordUser.aspx?codUser={0}&zoom=15;
private string GetLocation(BarcoViewModel barcoViewModel)
{
return string.Format(url, barcoViewModel.SapId);
}
But it will not work, would anyone have an example of how I insert this into view ?
How would I do the controller method returns this url with the?******** EDIT *******
Based on peer response
This is my Controller code:
http://npaa1215.example.com/gisb_prod/integration/coordUser.aspx?codUser=30071665&zoom=15
[HttpGet]
private string GetLocation(BarcoViewModel barcoViewModel)
{
return string.Format(url, barcoViewModel);
}
[HttpPost]
public RedirectResult RedirectTo(BarcoViewModel barcoViewModel)
{
string destination = GetLocation(barcoViewModel);
return RedirectPermanent(destination);
}
This is the View
<a href="@Url.Action("RedirectTo","Barcos", new { id = item.SapId })" class="btn btn-danger">
<span title="Excluir" class="glyphicon glyphicon-alert"></span>
</a>
But even making these additions, I still get the following error: