i am new in asp.net mvc3 . i am building my site in which i am facing a problem that i have a controller named Home
and a method in it named Index
and this index method takes a parameter id now according to this situation a valid url should be like this "http://www. counterexample.com/Home/Index/1" but what should i do if a user types a url like this "http://counterexample.com/whatsisthis" . It will definately give 404
error but i want to do that when any one types a URL like this he should be redirected to my another controller named Thunder
on method ErrorDetails
and all the character which user types in url after / should come to this method as parameter like following
public class ThunderController : Controller
{
public ActionResult ErrorDetails (string id)
{
var params = id ; // and the text "whatisthis" should store in param .
return View();
}
}
Please note that user can type any url like
i want that all these URL or any URL that doesn't exists should redirect to my method 'ErrorDetails' . Thanks