title: Is using URL query string variables still RESTful
body: <p>I'm presented with a problem of using query string variables in a RESTful Asp.net MVC application. Does that violate the RESTful pattern?</p>
  
  <p>The thing is that Asp.net MVC uses default route like:</p>
  
  <pre><code>/controller/action/id
  </code></pre>
  
  <p>I have to pass through another controller+action combination like:</p>
  
  <pre><code>/controller/action/id/controllerX/actionX
  </code></pre>
  
  <p>but this won't work if I'd be in the root of my application, because the first three parameters will be omitted and the last two will be treated as the first couple.</p>
  
  <p>Instead of this I'm tempted to use this notation instead:</p>
  
  <pre><code>/controller/action/id?Param=controllerX/actionX
  </code></pre>
  
  <p>Which would also work on root</p>
  
  <pre><code>http://domain/?Param=controllerX/actionX
  </code></pre>
  
  <p><strong>But is this RESTful?</strong></p>
  
  <h2>A bit of an explanation</h2>
  
  <p>I want to have a more modular approach to my views than the normal built-in with PartialViews. Because if I have a partial view that gets displayed on many pages I have to add vide data for that particular partial view in <strong>every single</strong> controller action that returns a view that uses that particular partial view. And I think that's a wrong way of doing things. Controllers become dependant on partial views that may (or god forbid <em>may not</em> ) be part of the main view.</p>
  
  <p>rendering actions instead of partial views come to the rescue. I use my own <code>Html.RenderAction()</code> that calls into some controller's action that prepares its own data only. Great this works fine.</p>
  
  <p>First problem was with HTTP method that got propagated to all RenderAction actions. So I changed it and I can control HTTP method as I like. Some actions may always be using GET no matter if the main view was posted back (thus using POST).</p>
  
  <p>The problem is when these actions return partial views with their own FORM elements. Since my sub actions can't be directly posted to (because they wouldn't know which view to return) they actually post to the view instead. All sub actions with forms usually have propagated HTTP method from the main view, so they will actually enter postback action execution.</p>
  
  <p>The thing is that only the actual form that was being posted back should execute its POST action. Others should just use GET method. Here's where my second controller/action pair comes into play. Every sub action form posts back to</p>
  
  <pre><code>mainViewController/action/?PostForm=controller/action
  </code></pre>
  
  <p>where the second parameter helps deciding which sub action rendering should propagate POST method to it. That particular form will be validated as defined in its post action.</p>
  
  <p>I hope this explains my problem a bit more with a concrete example. This problem is related to my <a href="https://stackoverflow.com/questions/1804884">yesterday's question</a>.</p>