How to catch page not found error when redirecting
-
There is a virtual path(http://server1/files/test.xls). From asp.net web app, I have to redirect to above path. If test.xls does not exist in the path, I have to display unauthorized page. I tried using if (File.Exists(Server.MapPath(URL))) but it gives an error "it is not a valid virtual path".
------------------------------------------------------------ "The only true wisdom is in knowing you know nothing." --Socrates
-
There is a virtual path(http://server1/files/test.xls). From asp.net web app, I have to redirect to above path. If test.xls does not exist in the path, I have to display unauthorized page. I tried using if (File.Exists(Server.MapPath(URL))) but it gives an error "it is not a valid virtual path".
------------------------------------------------------------ "The only true wisdom is in knowing you know nothing." --Socrates
-
There is a virtual path(http://server1/files/test.xls). From asp.net web app, I have to redirect to above path. If test.xls does not exist in the path, I have to display unauthorized page. I tried using if (File.Exists(Server.MapPath(URL))) but it gives an error "it is not a valid virtual path".
------------------------------------------------------------ "The only true wisdom is in knowing you know nothing." --Socrates
Try this if(File.Exitst(Server.MapPath("~/files/test.xls"))) { Redirect to the path; } else { Redirect to Unauthorized page. } Server.MapPath append the specified path to root path. ex: http://server1 say root path then in if contion check for the path 'http://server1/files/text.xls'
smile :-)