Note that there are some explanatory texts on larger screens.

plurals
  1. POobject oriented url scheme in asp.net mvc 2
    text
    copied!<p>I'd like to modify the standard ASP.NET MVC URL routes </p> <pre><code>http://example.com/Controller/Action[/Id] </code></pre> <p>to something like:</p> <pre><code>http://example.com/Controller/Id/Action </code></pre> <p>Modifying the route scheme is trivial but I'm getting into trouble when handling default values. I would need these URLs</p> <pre><code>http://example.com/Controller/ -&gt; Maps to Index() -&gt; List of items http://example.com/Controller/Create http://example.com/Controller/Id[/Details] -&gt; Maps to Details(id) http://example.com/Controller/Id/Edit -&gt; Maps to Edit(id) http://example.com/Controller/Id/Delete -&gt; Maps to Delete(id) </code></pre> <p>Yikes! This means quite a few routes instead of the nice default one. Or can I use URL parameters with default values in the middle of the URL?</p> <p>The next step is to use a friendly (yet unique!) object reference (eg customer name. Let's assume it is unique) instead of a DB record identity (id). Such as:</p> <pre><code>http://example.com/Controller/Name[/Details] -&gt; Maps to Details(id) </code></pre> <p>So far so good but I'm not sure it's a good idea to use this for the Edit (and possibly delete) page: The edit form lets user modify the object name, leading to possible mismatches in url. Should I stick to the id in Edit URLs?</p> <p>Did anyone experience with such URLs? Did you push the idea to hierarchical systems? Is this all a good idea or will I dive into more trouble than benefits?</p> <p>TIA for your thoughts.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload