maksymiuk maksymiuk - 5 months ago 24
C# Question

Having trouble with IUrlHelper

I have a method like so:

public async Task<IActionResult> Index(string token)

And when i use the following line:

string url = Url.Action("Index", "Confirm", "mViH%2BZBz4l2%2Bx97rackKlFTWLVeD4xl9c%2B6ggbjbXzpAT%2BLP%2BKWvLqGymZSgV7GEPoXPSRHx6vO1ytaKPbfYrON%2BqP21EGMop3hW1%2BwoHL0Xf7bDSS5EHiqyuwNmiiJiMAYZPgr%2FCe%2FXyZFLCy%2FbfuGCOK3iawGOhdD0DyignbUC3xNybkfZkJNaXNHJlHnIv5eu8Z4wjzFkMmb1SOi5YmIzfT%2FjFovhy6fVFbDQXsc0GBzKqNsZjCudTKSPbMoRV6%2FAjw%3D%3D");

url ends up being:


Instead of:


Does anyone know why this is the case? Nothing i've tried has worked to go around this. And if i create the link manually and use it it will work.

Answer Source

You need to provide route values.

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. The object is typically created by using object initializer syntax.

string url = Url.Action("Index", "Confirm", new { token = "...." });
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download