I'm using Url.Action to generate an absolute URL to send in an email. The link is generated inside a controller.
ConfirmLink = Url.Action(
"ConfirmEmail",
"Account",
new { userId = user.Id, code },
HttpContext.Request.Scheme
)
For some reason, in local, I have this result:
http://localhost:5102/account/confirm-email?userId=10&code=CfDJ8JH5BJKUsPZDnCLwFc3HSEHfe9Fk00NHiJqk36VbvkDbbV39AI7HY5m9pXVItwYE9%2B9ElTcnBSZiDNQ%2FmO5lx1tSnuvDmhzdzGlCQCfPQVe%2B21Nw03uNuBWoO8HCVivqzfudti579bWiaLW6PuuQQimn449YymVjgV3R36HeQID26jTmAxizDTqOsF1%2FvQc5Zw%3D%3D
but I have this result, without the domain/https protocol, in staging/prod:
http:///account/confirm-email?userId=10&code=CfDJ8JH5BJKUsPZDnCLwFc3HSEHfe9Fk00NHiJqk36VbvkDbbV39AI7HY5m9pXVItwYE9%2B9ElTcnBSZiDNQ%2FmO5lx1tSnuvDmhzdzGlCQCfPQVe%2B21Nw03uNuBWoO8HCVivqzfudti579bWiaLW6PuuQQimn449YymVjgV3R36HeQID26jTmAxizDTqOsF1%2FvQc5Zw%3D%3D
I'm using ASP .NET Core with "Microsoft.AspNetCore.Mvc": "1.1.0"
.
Application published to IIS.
I used to have the same issue before and the code below works fine for me.
var ConfirmLink = Url.Action(
"ConfirmEmail",
"Account",
new { userId = user.Id, code },
HttpContext.Request.Scheme,
HttpContext.Request.Host.Value //HttpContext.Request.Host.ToString()
)
or manually
var ConfirmLink = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}{Url.Action("ConfirmEmail", "Account")}";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With