iam trying to tell the page to open a certain aspx if it exists otherwise it should redirect to another page here the code iam using:
protected void Page_Load(object sender, EventArgs e)
{
string str = "~/User" + "/" + Page.User.Identity.Name + "/" + Page.User.Identity.Name + ".aspx";
FileInfo fi = new FileInfo(str);
if (fi.Exists) {
Response.Redirect(str);
}
else {
Response.Redirect("Page.aspx");
}
}
but i will always redirect to the page.aspx even if the original page exists
thanks
You need to pass the full path to FileInfo. Use
Server.MapPathto map from your virtual path to a full path, like this: