【问题标题】:MVC router throws invalid character in the URLMVC 路由器在 URL 中抛出无效字符
【发布时间】:2012-02-23 08:41:18
【问题描述】:

我在 MVC3 应用程序中使用以下路由

context.MapRoute("RoutName", "GetReport/{Id1}/{Id2}/{requestId}/{customerId}/
{CustomerVersion}/{Code}", new {controller= "ControllerName",action = "GetReport" });

此路由适用于本地环境中的以下 URL

http://localhost/ControllerName/GetReport/104334/120531211240541002/120531211240551002
/120531211237331002/1/Code

但在服务器中,我收到“由于 URL 中的无效字符而阻止访问”。 MVC中的URL长度有限制吗?

任何输入都会很棒。

【问题讨论】:

标签: asp.net-mvc-3


【解决方案1】:

我已经在一个空的 MVC3 项目中实现了你的代码,但我无法触发你的错误,这里的代码可以正常工作。

动作链接:

@Html.ActionLink("Test", "GetReport", "Home", new { Id1 = 104334, Id2 = 120531211240541002, requestId = 120531211240551002, customerId = 120531211237331002, CustomerVersion = 1, Code = "Code" }, null)

动作结果:

public ActionResult GetReport(string Id1, string Id2, string requestId, string customerId, string CustomerVersion, string Code)
        {
            return new EmptyResult();
        }

你的版本有什么不同?

【讨论】:

  • 看起来服务器中的问题是由其他一些组件引起的,现在它似乎可以正常工作。感谢您对它进行挖掘。
  • 没问题,很高兴能帮上忙。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-21
  • 1970-01-01
  • 1970-01-01
  • 2015-05-22
  • 2012-06-21
  • 1970-01-01
相关资源
最近更新 更多