Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have link facility for users on page..users can enter link and disply it..if that link is not present or not valid means not contains "htttp://" then user should redirect to 404 page not found page or show popup..how to do it?
Posted

Add another Controller Action Method, that would take exception as parameter.
From each link click action put the logic in try catch block and catch the exception and inside the catch :
C#
try{
//code goes here...
}
catch(Exception ex)
{
    if(es.Message == "check for the message matching http:404")
       {
          return RedirectToAction("NotFound");
       }
}

public ActionResult NotFound()
{
    return View();
}


Hope this helps
Thanks
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900