After migrating to the ASP.NET Core 3.0 . The Url.Action() returns null for valid action, controller. This worked in ASP.NET core 2.2
The action name does not contain async as explained in Microsoft Doc for migration to core 3.0
Configure method
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
ConfigureServices method
services.AddControllersWithViews()
.AddControllersAsServices()
.AddSessionStateTempDataProvider()
.AddMvcLocalization();
Eg
// url is null
string url = Url.Action("DeleteAccount", "Manage", null);
What am i missing?
I have met same question as yours. I think you haven't AddNewtonsoftjson in your configureServices function. Try to add it.
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
services.AddControllersWithViews().AddNewtonsoftJson();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.