RavenDB Ids and ASP.NET MVC3 Routes
Posted
by
goober
on Stack Overflow
See other posts from Stack Overflow
or by goober
Published on 2010-12-24T18:49:41Z
Indexed on
2010/12/24
18:54 UTC
Read the original article
Hit count: 318
Hey all,
Just building a quick, simple site with MVC 3 RC2 and RavenDB to test some things out.
I've been able to make a bunch of projects, but I'm curious as to how Html.ActionLink() handles a raven DB ID.
My example: I have a Document called "reasons" (a reason for something, just text mostly), which has reason text and a list of links. I can add, remove, and do everything else fine via my repository.
Below is the part of my razor view that lists each reason in a bulleted list, with an Edit link as the first text:
@foreach(var Reason in ViewBag.ReasonsList)
{
<li>@Html.ActionLink("Edit", "Reasons", "Edit", new { id = Reason.Id }, null) @Reason.ReasonText</li>
<ul>
@foreach (var reasonlink in Reason.ReasonLinks)
{
<li><a href="@reasonlink.URL">@reasonlink.URL</a></li>
}
</ul>
}
The Problem
This works fine, except for the edit link. While the values and code here appear to work directly (i.e the link is firing directly), RavenDB saves my document's ID as "reasons/1".
So, when the URL happens and it passes the ID, the resulting route is "http://localhost:4976/Reasons/Edit/reasons/2". So, the ID is appended correctly, but MVC is interpreting it as its own route.
Any suggestions on how I might be able to get around this? Do I need to create a special route to handle it or is there something else I can do?
© Stack Overflow or respective owner