Hi guys
I have the following case where I want to accept the following routs
'/type/view/23' or '/type/view/hats'
where 23 is the Id for hats.
The controller looks something like this:
public class TypeController
{
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult View(int id)
{
...
}
}
Now if they pass in 23 no problems. If they pass in hats, I have some work to do. Now I was wondering in this case would I translate hats to 23 by using an ActionFilter that looks to see if the value passed in as the id is an int (if so check that it exists in the database) or if it is a string looks up the database for what the id of the string that has been passed in is. In either case if a match is not found I would want redirect the user to a different action.
Firstly is the approach I have named correct, secondly is it posible to do a redirect from within an ActionFilter.
Cheers Anthony