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.");
}

```
In the case above your action could accept two strings instead of a concrete type. 

Another possibility is having two actions. Each action taking one of your types. I'm assuming that functionality each type is basically the same. Once the values have been extracted hand them off to a method. In your case method will probably be the same for each action.

```
public ActionResult Method1(Record record)
{
ProcessAction(record.id, record.Property);

}

public ActionResult Action2(OtherRecord record)
{

ProcessAction(record.id, record.OtherProperty);

}

private void ProcessAction(string id, string otherproperity)
{
//make happen
}

```