0

We have a site that when inserting the code of a user it shows the location of that user

I have a example URL:

http://npaa1215.example.com/gisb_prod/integration/coordUser.aspx?codUser=30071665&zoom=15

My idea is to use this URL in my application and pass the user code that is in my application to this URL

How could I insert a parameter that comes from my application, in the part of the URL that it asks the "codUser"

In the example it is pointing to the user with "codUser=30071665"

Would anyone have an idea or example?

Jhensen
  • 71
  • 7

4 Answers4

0

i suggest you this simple solution

string COD_USER="30071665";
Response.Redirect("http://npaa1215.example.com/gisb_prod/integration/coordUser.aspx?codUser="+COD_USER+"&zoom=15");

I wish that help you

MBARK T3STO
  • 329
  • 1
  • 11
0

Maybe the easier method is using `HttpUtility.ParseQueryString

string myUrl = "http://npaa1215.example.com/gisb_prod/integration/coordUser.aspx?zoom=15";
var uriBuilder = new UriBuilder(myUrl);
var query = HttpUtility.ParseQueryString(uriBuilder.Query);
query["COD_USER"] = "30071665";
query["ANOTHER_QUERY_PARAMETER"] = "ParameterValue";
uriBuilder.Query = query.ToString();
myUrl = uriBuilder.ToString();

You can try with that, basically, you might use the ParseQueryString method and you can add with query["COD_USER"] = "30071665" or any other key that you want.

Benjamin RD
  • 11,516
  • 14
  • 87
  • 157
0

Here's how i resolved the problem:

Controller:

[HttpGet]
public RedirectResult RedirectTo(int id)
{
string location = GetLocation(id);
  return RedirectPermanent(location);
}

string url = "http://npaa1215.example.com/gisb_prod/integration /coordUser.aspx?codUser={0}&zoom=15";
private string GetLocation(int id)
{
  return string.Format(url, id);
}

View

href="@Url.Action("RedirectTo","Barcos", new { id = item.SapId })" class="btn btn-danger">
<span title="Excluir" class="glyphicon glyphicon-alert"></span>
</a>
Jhensen
  • 71
  • 7
-1

The code below just take the userCode parameter and return the url with the given parameter inserted at the right place :

string url = http://npaa1215.example.com/gisb_prod/integration/coordUser.aspx?codUser={0}&zoom=15;

private string GetLocation(int userCode) 
{
  return string.Format(url, userCode);
}
WebAddict
  • 51
  • 5