2

Configured Route:

routes.MapRoute(
  name: "RedirectToProduct",
  url: "product/page/p{productId}/{shortName}",
  defaults: new { controller = "Product", action = "RedirectToProduct", shortName = UrlParameter.Optional }
);

Action Method:

public class ProductController : Controller
{
    public async Task<ActionResult> RedirectToProduct(string productId, string shortName)
    {
    }
}

Problem..

What I want is- whether I add DOT (.) in the end OR not in productUd parameter, call should go in the controller's action method.

Thanks in advance!

nunu
  • 3,184
  • 10
  • 43
  • 58
  • Any other routes defined before that one that might be interfering? – Daniel J.G. Feb 06 '15 at 09:54
  • no @DanielJ.G., there are only 2 routes defined. This is the 1st one and then the default one. – nunu Feb 06 '15 at 09:55
  • I feel that your question and description conflict. – dotnetstep Feb 06 '15 at 09:56
  • Should work without issues. Just tried that and it all works here. You have a test project that simulates the issue? – L-Four Feb 06 '15 at 10:08
  • Hello @L-Three, Thanks for the efforts.. I just realized that- when I use DOT (.) at the end, it is NOT working... E.g. http://localhost:1234/product/page/p118.5 – nunu Feb 06 '15 at 10:11
  • Do you mean you have the problem only if you use a dot? Bedause that too should just work. It would be best to provide a sample solution, because it should work. – L-Four Feb 06 '15 at 10:13
  • Yes @L-Three, when I use DOT in productId, it is NOT calling action method, it shows HTTP 404 error in browser.. – nunu Feb 06 '15 at 10:14
  • Doesn't make sense. Provide a sample app... – L-Four Feb 06 '15 at 10:15
  • @L-Three Just try to use this url in your sample app... http://localhost:1234/product/page/p118.5 You will see the issue.. You will NOT get a call in action method.. May be because it treat as an extension... – nunu Feb 06 '15 at 10:16

1 Answers1

2

If the dot is the problem, like product/page/p118.5, then add runAllManagedModulesForAllRequests = true to your web.config, like:

<system.webServer>
   <modules runAllManagedModulesForAllRequests="true">
     ...
   </modules>
 </system.webServer>
L-Four
  • 13,345
  • 9
  • 65
  • 109
  • Thanks @L-Three ! Do you think there there is any side-effect of having this flat to true?? – nunu Feb 06 '15 at 10:32
  • Have a look at http://stackoverflow.com/questions/11048863/modules-runallmanagedmodulesforallrequests-true-meaning – L-Four Feb 06 '15 at 10:34