Home > Net >  The path can't take effect the Core ASP.NET MVC project
The path can't take effect the Core ASP.NET MVC project

Time:11-04

Built a ASP.NET Core 3.1 project, and then use the MVC attribute routing, Startup class is as follows:
 
Public class Startup
{
Public void ConfigureServices (IServiceCollection services)
{
Services. AddSingleton (a);
Services. AddMvc (sa=& gt; Sa. EnableEndpointRouting=false);
}

Public void the Configure (IApplicationBuilder app, IWebHostEnvironment env)
{
If (env. IsDevelopment ()) app. UseDeveloperExceptionPage ();

App. UseStaticFiles ();
App. UseMvc ();
App. The Run (async context=& gt; Await the context. The Response. WriteAsync (" Last Middleware!" ));
}
}

Controller (within the Controllers this child namespace) is as follows:
 
[the Route (" [controller] ")]
Public class SoftwareQueryController: Controller
{
Private readonly ISoftwareRepository _softwareRepository;

Public SoftwareQueryController ISoftwareRepository (sr)
{
_softwareRepository=sr;
}

[the Route (" [action]/{namePattern} ")]
Public ViewResult Softwares (string namePattern)
{
Var SWS=_softwareRepository. GetSoftwares (namePattern);
Return the View (SWS);
}
}

Don't know what code needs to stick,
Start debugging, the URL is: http://localhost:58261/SoftwareQuery/Softwares/s1
A browser error information:


If the above URL SoftwareQuery or Softwares of random change, will go to the last middleware, but the above URL is always this error,
Have tried to delete the app. UseStaticFiles (), there is no change, so not the problem, why the routing is no effect, but as the directory access?
  • Related