c# - Url.Route in ApiController doesn't include hostname -


from apicontroller, generating password reset link emailed user. works except url.route function doesn't generate link hostname. i'm not sure if it's because i'm using localhost that's causing problem.

this code generate link

string callbackurl  = url.route("defaultapi", new { controller = "account", action= "resetpassword", userid = user.id, code = code }); 

this link generated

https:///api/account/resetpassword?userid=aaaaaaaaaa&code=aaaaaaaaa 

notice https:///api, should include hostname , port https://localhost:4040/api. why isn't hostname being included?

url.route generates relative urls only. absolute url, use url.link:

string callbackurl  = url.link("defaultapi", new { controller = "account", action= "resetpassword", userid = user.id, code = code }); 

Comments