aspnetcore mvc默承認以處理ajax的put,delete之類的操做,但是表單form提交就找不到路由了。html
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { ... app.UseHttpMethodOverride(new HttpMethodOverrideOptions { FormFieldName = "_method" }); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
添加上HttpMethodOverride中間件就能夠把經過在表單加入下面的方式模擬put,delete類提交操做.ajax
<input type="hidden" name="_method" value="put" />