[英]How to stop area from automatically being added to the URL when using Url.Action?
调用此方法的 controller 在 Areas/AdminPortal 中,但我试图调用不在 Admin Portal 中的 controller 操作。 我有这段代码,但它会自动将 /AdminPortal 分配给 url 的开头。
string tokenVerificationUrl = Url.Action(nameof(AccountController.VerifyEmail).AspName(), nameof(AccountController).AspName(),
new {id = user.Id, token = emailConfirmationToken }, Request.Scheme);
返回 localhost:1234/AdminPortal/Account/VerifyEmail/tokenValue
我希望它返回 localhost:1234/Account/VerifyEmail/tokenValue
要删除该区域,只需将 area = "" 添加到传递的值即可。
string tokenVerificationUrl = Url.Action(nameof(AccountController.VerifyEmail).AspName(), nameof(AccountController).AspName(),
new { area = "", id = user.Id, token = emailConfirmationToken }, Request.Scheme);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.