1
我最近開始學習ASP.Net Core來開發MVC Web API。但我甚至無法讓我的Hello World世界繼續運行。ASP.Net核心MVC項目不能配置路由?
在Startup.cs
我寫道:
public void ConfigureServices(IServiceCollection services)
{
services.AddRouting();
services.AddMvc(routes =>
{
routes.MapRoute(
"default",
"{version?}/{controller=Home}/{action=Index}/{id?}");
});
}
和控制檯說:
error CS1929: 'MvcOptions' does not contain a definition for 'MapRoute' and the best extension method overload 'MapRouteRouteBuilderExtensions.MapRoute(IRouteBuilder, string, string)' requires a receiver of type 'IRouteBuilder'
沒有工作!我想我已經失明瞭 – Desmond