তবে এটি সমাধানের সঠিক উপায় কী তা আমার জানতে হবে
সাধারণভাবে, EnableEndpointRoutingপরিবর্তে আপনার ব্যবহার করা উচিত UseMvcএবং সক্ষম করার জন্য বিশদ পদক্ষেপের জন্য আপনি আপডেট রাউটিং স্টার্টআপ কোডটি উল্লেখ করতে পারেন EnableEndpointRouting।
কেন এন্ডপয়েন্ট রাউটিংয়ে ইউজএমভিসি () ফাংশন প্রয়োজন হয় না।
জন্য UseMvc, এটি ব্যবহার করে the IRouter-based logicএবং EnableEndpointRoutingব্যবহার করে endpoint-based logic। তারা বিভিন্ন যুক্তি অনুসরণ করছে যা নীচে পাওয়া যাবে:
if (options.Value.EnableEndpointRouting)
{
var mvcEndpointDataSource = app.ApplicationServices
.GetRequiredService<IEnumerable<EndpointDataSource>>()
.OfType<MvcEndpointDataSource>()
.First();
var parameterPolicyFactory = app.ApplicationServices
.GetRequiredService<ParameterPolicyFactory>();
var endpointRouteBuilder = new EndpointRouteBuilder(app);
configureRoutes(endpointRouteBuilder);
foreach (var router in endpointRouteBuilder.Routes)
{
// Only accept Microsoft.AspNetCore.Routing.Route when converting to endpoint
// Sub-types could have additional customization that we can't knowingly convert
if (router is Route route && router.GetType() == typeof(Route))
{
var endpointInfo = new MvcEndpointInfo(
route.Name,
route.RouteTemplate,
route.Defaults,
route.Constraints.ToDictionary(kvp => kvp.Key, kvp => (object)kvp.Value),
route.DataTokens,
parameterPolicyFactory);
mvcEndpointDataSource.ConventionalEndpointInfos.Add(endpointInfo);
}
else
{
throw new InvalidOperationException($"Cannot use '{router.GetType().FullName}' with Endpoint Routing.");
}
}
if (!app.Properties.TryGetValue(EndpointRoutingRegisteredKey, out _))
{
// Matching middleware has not been registered yet
// For back-compat register middleware so an endpoint is matched and then immediately used
app.UseEndpointRouting();
}
return app.UseEndpoint();
}
else
{
var routes = new RouteBuilder(app)
{
DefaultHandler = app.ApplicationServices.GetRequiredService<MvcRouteHandler>(),
};
configureRoutes(routes);
routes.Routes.Insert(0, AttributeRouting.CreateAttributeMegaRoute(app.ApplicationServices));
return app.UseRouter(routes.Build());
}
জন্য EnableEndpointRouting, এটি ব্যবহার করে EndpointMiddleware এন্ড পয়েন্ট করার অনুরোধ রুট।