別のコントローラーやアプリケーションへのリダイレクトに問題があります。ASP COREのURLにリダイレクト
public IActionResult Redirect(NotificationItemViewModel model)
{
NotificationItemToggleReadCommand command = new NotificationItemToggleReadCommand();
command.Id = new EntityId(model.Id);
command.MarkAsRead = true;
var result = CommandProcessor.Run(command);
RedirectResult redirectResult = new RedirectResult(model.Subject.Url,true);
return redirectResult;
}
マイmodel.Subject.Urlこの形式で、たとえば次のとおりです:
私のリダイレクトアクションは次のようになりIdentity/User#/Details/b868b08c-b3ba-4f45-a7b6-deb02440d42f
それはエリア/コントローラ/アクション/ IDです。 問題は、私のRedirectResultがに私をリダイレクトすることです:
notifications/Identity/User#/Details/b868b08c-b3ba-4f45-a7b6-deb02440d42f
とそのルートが最初にこのコントローラ名を遮断するために、このリダイレクトを強制するにはどうすればよい(コントローラ/面積/コントローラ/アクション/ ID) 存在しないのですか?
マイルート:助けを
app.UseMvc(routes =>
{
routes.MapRoute("areaRoute", "{area:exists}/{controller}/{action=Index}/{id?}");
routes.MapRoute(
name: "controllerActionRoute",
template: "{controller}/{action}",
defaults: new { controller = "Home", action = "Index" },
constraints: null,
dataTokens: new { NameSpace = "default" });
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
感謝。
ありがとうございました。残念ながら私はabsouleのURLを取得する可能性はありません。私はいつもこの相対的な1つを取得し、このURLは他のアクションとコントローラを指すことができるので、私は第2の解決策を使用することはできません。 – Ridikk12
私の更新を見てくださいまた私は "ユーザー#"を理解していません。それは問題を引き起こすかもしれない。 – dotnetstep