Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 628
galets Avatar asked Dec 16 '12 19:12

galets


2 Answers

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>
like image 105
kabaros Avatar answered Nov 10 '22 09:11

kabaros


Yes... See comments, the handler mapping was a problem.

I changed URL from QRCode/address1/33.33 to QRCode/address1/33.33/ and mapping worked fine

like image 45
galets Avatar answered Nov 10 '22 09:11

galets