0

I'm playing around with Raven DB and MVC 2. By default, the id in Raven will be e.g. "suggestions/1234" for an entity called Suggestion.

This causes problems with routing when I write like this:

<%: Url.Action("Delete", "Suggestion", new { id = suggestion.Id }) %>

The url will be /Suggestion/Delete/suggestions/14337 which won't work.

Can this be solved in the routing, or do I have to change the format of the id in Raven? And how do I do that?

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
Allrameest
  • 4,364
  • 2
  • 34
  • 50

2 Answers2

3

Change your route from {controller}/{action}/{id} to {controller}/{action}/{*id}. This is called a "catch-all" route; more details on MSDN.

Alternatively, you could pass the id as a query parameter.

Stephen Cleary
  • 437,863
  • 77
  • 675
  • 810
0

You will not be able to encode the forward slash by default.

Change the id to suggestions_1234 or try to use this setting:

<uri> 
    <schemeSettings>
        <add name="http" genericUriParserOptions="DontUnescapePathDotsAndSlashes" />
    </schemeSettings>
</uri>

I did not check if the config setting works yet. And I can't do it right now because the soccer starts in 5min.

URL-encoded slash in URL

Community
  • 1
  • 1
Mathias F
  • 15,906
  • 22
  • 89
  • 159