asp.net-core – ASP.Net核心RC1:System.ArgumentException:路
请注意:由于答案显示此问题特定于ASP.Net Core Release Candidate 1.
在ASP.Net Core / MVC 6中访问URL http://localhost:58000/Admin/RebuildIndex/AspNetUserRoles/PK_IdentityUserRole%3Cstring%3E 给出了这个错误:
这是由于<和> URL中的字符.如果我访问不同的页面,如http://localhost:58000/Admin/RebuildIndex/AspNetRoles/RoleNameIndex,那么它工作正常. 我的路线是这样的: app.UseMvc(routes => { // Area route routes.MapRoute(name: "areaRoute",template: "{area:exists}/{controller}/{action}",defaults: new { controller = "Home",action = "Index" }); // Default route routes.MapRoute( name: "default",template: "{controller=Home}/{action=Index}/{id?}"); }); 我访问的控制器看起来像这样: [Route("Admin")] public class AdminController : Controller { [Route("RebuildIndex/{tableName}/{indexName}")] [HttpGet] [Authorize(Roles="Admin")] public async Task<IActionResult> RebuildIndex(string tableName,string indexName) { // ... } } 在以前版本的ASP.Net中,我们使用Web.Config中的httpRuntime标记来放松一些东西,当我们得到“从客户端(&)检测到一个潜在危险的Request.Path值”错误.所以我在web.config中尝试了以下(以及它的一些变体)但没有成功: <system.web> <httpRuntime requestValidationMode="2.0" relaxedUrlToFileSystemMapping="true" requestPathInvalidCharacters="" /> </system.web> 但是,查看错误消息时,此错误似乎是因为请求作为静态文件处理而不是提供给MVC控制器. 如何在ASP.Net Core中解决这个问题?如果只允许特定路由的解决方案,这将是一件好事. 解决方法
这是RC2已经记录并修复的问题(根据
the roadmap,应该在2016年2月发布).
>检查AspNet.StaticFiles仓库的issue 82. 如果您想知道,可以查看 public bool TryGetContentType(string subpath,out string contentType) { string extension = GetExtension(subpath); if (extension == null) { contentType = null; return false; } return Mappings.TryGetValue(extension,out contentType); } private static string GetExtension(string path) { // Don't use Path.GetExtension as that may throw an exception if there are // invalid characters in the path. Invalid characters should be handled // by the FileProviders if (string.IsNullOrWhiteSpace(path)) { return null; } int index = path.LastIndexOf('.'); if (index < 0) { return null; } return path.Substring(index); } 所以我想你可以等待RC2发布或使用StaticFiles repo的本地克隆. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net – 自动修复与’ASPStateTempSessions’相关的temp
- 什么是ASP.NET的最佳/推荐的CAPTCHA组件
- 何时使用PageAsyncTask(异步asp.net页面)的示例
- asp.net – 在Visual Studio中编辑文件后,如何解决由于“ap
- asp.net-mvc – CKEditor和ASP.Net MVC 3 RequiredAttribut
- asp.net-mvc – .NET MVC – 调用控制器来自另一个控制器动
- .Net Core微服务入门全纪录(三)——Consul-服务注册与发现
- ASP.Net vs MVC vs WebAPI和UseTaskFriendlySynchronizatio
- 在ASP.NET Core上实施每个租户策略的数据库
- ASP.NET状态管理在适当的情况下
- asp.net-mvc – 为什么我的IIS Express Web应用程
- asp.net – 更新ValidationSummary列表控件模糊?
- asp.net – 如何解决“Chunked body没有正确终止
- 何时使用ASP.NET MVC与ASP.NET Web窗体?
- asp.net-mvc – Umbraco Surface Controller或Re
- ASP.NET MVC:数据注释验证足够了吗?
- .net – 在.aspx页面上引用代码隐藏属性?
- asp.net-mvc-3 – 型号型号无法更新mvc
- 日志记录 – ASP.NET MVC 4 Web Api:诊断功能
- asp.net-mvc – asp.net MVC antiorgerytoken异常