MVC4项目 - 不能在参数值点? [英] MVC4 project - cannot have dot in parameter value?

查看:119
本文介绍了MVC4项目 - 不能在参数值点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MVC4项目,我试图得到它的工作像/ QR code /地址/金额的URL。下面是它的声明方式:

I have an MVC4 project, and I am trying to get it working on URLs like /QRCode/address/amount. Here's how it is declared:

路线:

routes.MapRoute(
    name: "QRCode",
    url: "QRCode/{address}/{amount}",
    defaults: new { controller = "QRCode", action = "Index" }
);

控制器:

public class QRCodeController : Controller
{
    public ActionResult Index(string address, double amount)
    {
         ...

问题是:

在网址为: QR code /地址1/33 ,一切工作正常,但如果在第二个参数的点,如: QR code /地址1 / 33.33 ,我得到一个HTTP错误404.0 - 未找到。

When URL is: QRCode/address1/33, all works fine, but if there is a dot in second parameter, such as: QRCode/address1/33.33, I am getting a "HTTP Error 404.0 - Not Found".

再宣布第二个参数字符串收益率相同的结果。

Re-declaring second parameter a string yields same result.

代替点率相同的结果,使用%2E

Using %2E in lieu of a dot yields same result

有人知道是怎么回事呢?我知道它在MVC3工作得很好。

Anybody knows what is going on here? I know it worked fine in MVC3

推荐答案

如果这是在IIS 7,然后添加到您的配置文件,它应该很好地工作:

if this is on IIS 7, then add this to your config file and it should work fine:

<system.web>
     <httpRuntime relaxedUrlToFileSystemMapping="true" />
</system.web>

这篇关于MVC4项目 - 不能在参数值点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆