Question: I have the following code which detects which search engine and what search term has been used:

```
if (document.referrer.search(/google\.*/i) != -1) {
    var start = document.referrer.search(/q=/);
    var searchTerms = document.referrer.substring(start + 2);
    var end = searchTerms.search(/&/);
    end = (end == -1) ? searchTerms.length : end;
    searchTerms = searchTerms.substring(0, end);
    if (searchTerms.length != 0) {
        searchTerms = searchTerms.replace(/\+/g, " ");
        searchTerms = unescape(searchTerms);
        alert('You have searched: '+searchTerms+' on google');
    }
}

```

That actually works, but unfortunately it doesn't work as expected sometimes.

Sometimes if the referrer was even not google i get an alert with the search term as : ttp://www.domain.com ( without H at the start ) i think that may lead to the bug.

Appreciate any help!

Answer: 
You could define an interface for those classes.

```
interface IRecord
{
    string RecordID { get; set; }
    string OtherProperties { get; set; }
}

```

and make the method receive the model by using that:

```
[HttpPost]
public ActionResult ValidateRecordID(IRecord model) 
{
    // TODO: Do some verification code here

    return this.Json("Validated.");
}

```
There is no direct way of binding data to a interface/abstract class. The DefaultModelBinder will try to instantiate that type, which is (by definition) impossible.

So, IMHO, you should not use that option. And if you still want to share the same controller action between the two views, the usual way of doing that would be using a [ViewModel](https://stackoverflow.com/questions/664205/viewmodel-best-practices).

Make your strongly-typed views reference that viewmodel. Make the single shared action receive an instance of it. Inside the action, you will decide which "real" model should be used...

If you need some parameter in order to distinguish where the post came from (view 1 or 2), just add that parameter to the ajax call URL.

Of course, another way is keeping what you have already tried (interface/abstract class), but you'll need a [custom Model Binder](http://weblogs.asp.net/bhaskarghosh/archive/2009/07/08/7143564.aspx) in that case... Sounds like overcoding to me, but it's your choice.

**Edit** After my dear SO fellow @Charles Boyung made a gracious (and wrong) comment below, I've come to the conclusion that my answer was not exactly accurate. So I have fixed some of the terminology that I've used here - hope it is clearer now.