, . , id int. , id, . , .
public class TypeController
{
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult View(string id)
{
Product product = null;
int productID = -1;
if (int.TryParse( id, out productID))
{
product = db.Products
.Where( p => p.ID == productID )
.SingleOrDefault();
}
else
{
product = db.Products
.Where( p => p.Name == id )
.SingleOrDefault();
}
if (product == null)
{
return RedirectToAction( "Error" );
}
...
}
}
, , , , , / , , , . , - , - , - . , , , , , int - , , , , , . , , - .