title: HTTP GET to return custom model with data from external database with Umbraco MVC Surface Controller
body: <p>I am currently working on an Umbraco MVC 4 project version 6.0.5. The project currently uses Vega.USiteBuilder to build the appropriate document types in the backoffice based on strongly typed classes with mapping attributes. Consequently, all my razor files inherit from UmbracoTemplatePageBase</p>
  
  <p>I am coming across a road block trying to invoke a HTTP GET from a razor file. For example a search form with multiple fields to submit to a controller action method, using a SurfaceController using Html.BeginUmbracoForm.</p>
  
  <p>My Html.BeginUmbracoForm looks like this</p>
  
  <pre><code>@using (Html.BeginUmbracoForm("FindTyres", "TyreSearch"))
  {
   // Couple of filter fields
  }
  </code></pre>
  
  <p>I basically have a scenario where I will like to retrieve some records from an external database outside of Umbraco (external to Umbraco Database) and return the results in a custom view model back to my Umbraco front end view. Once my controller and action method is setup to inherit from SurfaceController and thereafter compiling it and submitting the search, I get a 404 resource cannot be found where the requested url specified: /umbraco.RenderMVC.</p>
  
  <p>Here is my code snippet:</p>
  
  <pre><code>public ActionResult FindTyres(string maker, string years, string models, string vehicles)
          {
              var tyreBdl = new Wheels.BDL.TyreBDL();
              List&lt;Tyre&gt; tyres = tyreBdl.GetAllTyres();
  
              tyres = tyres.Where(t =&gt; string.Equals(t.Maker, maker, StringComparison.OrdinalIgnoreCase)
                                       &amp;&amp; string.Equals(t.Year, years, StringComparison.OrdinalIgnoreCase)
                                       &amp;&amp; string.Equals(t.Model, models, StringComparison.OrdinalIgnoreCase)
                                       &amp;&amp; string.Equals(t.Version, vehicles, StringComparison.OrdinalIgnoreCase)).ToList();
  
              var tyreSearchViewModel = new TyreSearchViewModel
              {
                  Tyres = tyres
              };
  
              ViewBag.TyreSearchViewModel = tyreSearchViewModel;
  
              return CurrentUmbracoPage();
          }
  </code></pre>
  
  <p>I then resort to using standard MVC, Html.BeginForm (the only difference). Repeating the steps above and submitting the search, I get the following YSOD error.</p>
  
  <blockquote>
    <p>Can only use UmbracoPageResult in the context of an Http POST when
    using a SurfaceController form</p>
  </blockquote>
  
  <p>Below is a snippet of the HTML BeginForm</p>
  
  <pre><code>@using (Html.BeginForm("FindTyres", "TyreSearch"))
  {
   // Couple of filter fields
  }
  </code></pre>
  
  <p>I feel like I am fighting the Umbraco routes to get my controller to return a custom model back to the razor file. I have googled alot trying to figure out how to do a basic search to return a custom model back to my Umbraco front end view till the extent that I tried to create a custom route but that too did not work for me.</p>
  
  <p>Does my controller need to inherit from a special umbraco controller class to return the custom model back? I will basically like to invoke a HTTP GET request (which is a must) so that my criteria search fields are reflected properly in the query strings of the url. For example upon hitting the search button, I must see the example url in my address browser bar</p>
  
  <blockquote>
    <p>http://[domainname]/selecttyres.aspx/TyresSearch/FindTyresMake=ASIA&amp;Years=1994&amp;Models=ROCSTA&amp;Vehicles=261</p>
  </blockquote>
  
  <p>Therefore, I cannot use Surface Controller as that will operate in the context of a HTTP Post.</p>
  
  <p>Are there good resource materials that I can read up more on umbraco controllers, routes and pipeline.</p>
  
  <p>I hope this scenario makes sense to you. If you have any questions, please let me know. I will need to understand this concept to continue on from here with my project and I do have a deadline.</p>