i want to redirect the user to this link with being able to pass variables
public ActionResult GoogleMapAddress(string address, string Area, string city, string zipCode)
{
return Redirect(string.Format(" https://www.google.co.za/maps/search/{0}/ ", address + Area + city + zipCode));
}
The View
@Html.ActionLink("Address", "GoogleMapAddress", "Orders", new { address="test", Area="test", city="test", zipCode="test" },new {target="_blank" })
The current method I have adds the Url link to the localhost link.Which gives the error- "A potentially dangerous Request.Path value was detected from the client (:)." and the url link(google) does work once I remove the added localhost link
As already mentioned in the comments the url needs to be properly constructed.
first construct and encode the inserted segment.
You then construct the complete URL with the base format and the escaped segment
And use that to do the redirect.
Complete code would look something like this
You could even consider validating the constructed URL before trying to use it with
if (Uri.IsWellFormedUriString(url, UriKind.Absolute))
Here is the solution for the error,"A potentially dangerous Request.Path value was detected from the client (:)"
Try these settings in webconfig file:
Controller code:
if you want to pass variable, give the value after the question mark like below