Reputation: 11652
My loging page in root/Account/Login.aspx
page when I click on contact us i need to redirect to root/contactus.aspx
page.
I used Response.Redirect("~/contactus.aspx")
in Master page (Site.Master)
Protected Sub lbContactUs_Click(sender As Object, e As EventArgs) Handles lbContactUs.Click
Response.Redirect("~/contactus.aspx")
End Sub
Still it is not redirecting to page.
Upvotes: 1
Views: 10272
Reputation: 5894
Add the following to your web.config
<configuration>
...
<location path="ContactUs.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
...
</configuration>
It seems that you have a deny all anonymous users rule set in your web.config
. If you need to allow anonymous users access to specific pages, while still leaving the rest of your site protected by forms authentication, you can use the location
tag to override the security for specific pages.
Upvotes: 4
Reputation: 32604
You are not redirecting properly.
Response.Redirect("/contactus.aspx", False);
Context.ApplicationInstance.CompleteRequest();
Do not use Response.Redirect(url)
. It calls Response.End
which is very taxing on the server.
Response.Redirect(url, false)
is much faster and more efficient.
Response.End
will raise a ThreadAbortException
which costs a lot for the server to do.
@Jason Kulatunga
's answer looks like it will solve your problem. The above information is just for good practice.
Upvotes: 6
Reputation: 7403
@James123: Use
Protected Sub lbContactUs_Click(sender As Object, e As EventArgs) Handles lbContactUs.Click
Response.Redirect("/contactus.aspx")
End Sub
this will redirect to root directory
Upvotes: 1