I am using Attribute Routing
in MVC4
application. I have set route to [Route("test-{testParam1}-{testParam2}")]
. Here `{testParam2}' may consist the word 'test'. For example, if I enter a url as below,
localhost:33333/test-temp-test-tempparam2
This gives me 404 error. Here in the url, here {testParam2}
is having two words test tempparam2
formatted to test-tempparam2
. When test
word is at last position of {testParam2}
, it runs good. That means if the url is like .../test-temp-tempParam2-test
runs good. But following give error. .../test-temp-test-tempParam2
.
Below is the code that may help...
[Route ("test-{testParam1}-{testParam2}")]
public ActionResult Foo (int testParam2) {...}
Now try following two url.
localhost:(port)/test-temp-1
localhost:(port)/test-test-temp-1
In my case second gives error. In this case first parameter is formatted to test-temp
from test temp
. First runs good.
How to solve this problem?