0

I am using System.IO.File.Exists(Server.MapPath(path)) in my code. Some time when a character (:) colon is coming then Server.MapPath is throwing an exception that System.Web.HttpException: '/MyWeb/pages/javascript:void(0).aspx' is not a valid virtual path.

How do i suppress this error and still call Server.MapPath()

Regards...

  • Why would that character even be in the path? Consider fixing that instead of hiding it. – Wutz Dec 11 '12 at 11:12
  • Actaully whenever a normal user will access and navigate the site then such issues/exceptions will not arise. On our production, we are using virus scan, and during this scan, this issue is encountered. So wanted to know how to suppress or handle this gracefully in the code. For example, whenever we need to convert a string to int, we use TryParse, which is a cleaner way of implementation and avoding the errors. I am looking for such similar kind of implementation, before calling or while calling server.MapPath(). – user1675605 Dec 11 '12 at 11:33

0 Answers0