Search code examples
asp.netasp.net-mvc-4

MVC4 project - cannot have dot in parameter value?


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:

Route:

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

Controller:

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

The problem is:

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.

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

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


Solution

  • 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>