Running IIS6.
So, '.' do not work in IIS6, but they work fine in the visual studio debugger and IIS7. Here's the steps to reproduce.
Steps to reproduce:
- Start with a blank MVC 3 project.
- Add A new view called "Index" and accept the defaults.
- Configure RegisterRoutes() as follows:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"QuerySomething",
"QueryStuff/Index/{*aString}",
new { controller = "QueryStuff", action = "Index", aString = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
Now, add a controller that returns Json:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcApplication1.Controllers
{
public class QueryStuffController : Controller
{
//
// GET: /QueryStuff/
public ActionResult Index(string aString)
{
return Json("aString:oye",JsonRequestBehavior.AllowGet);
}
}
}
Verify that the page is accessible:
You should get http 200.
Now try to get there with a '.' in the path
You should get a http 404 error. (Note that this error is NOT reproduceable when running through visual studio debugger. One must deploy the code to IIS.)
UPDATE
I modified Regex to route for email addresses and it made the problem even worse.
routes.MapRoute(
"QuerySomething",
"QueryStuff/Index/{aString}"
, new { controller = "QuerySomething", action = "Index" },
new { aString = @"\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b" }
);
With this its 404 everytime.