Redirection with ASP.Net friendly URLs

  • 1
In this post we are going to see how we can use Response.Redirect(Redirecttion) in asp.net friendly URLs. Before some day I have written a post about ASP.NET Friendly URLs – Cleaner, SEO friendly URLs. On that post one reader ‘Ramesh’ asked me that how we can do redirection with ASP.Net friendly URLs. So this post is in reply to Him.

How to redirect a page to ASP.Net friendly URLs:

Actually!! there is nothing to learn. It’s very easy You can directly use the ‘Response.Redirect’ with the ASP.Net friendly URLs. The NuGet Package itself takes care of all the things. You just need to write the route name as a parameter in ‘Response.Redirect’ and you are done!!

Uh!! don’t believe me!!. Let’s take a sample example. I am going to use by default template with ASP.NET Friendly URLs.  So for this example I have created a ASP.Net button in Default template AboutUs.aspx page. Once the click of that button we are going to use ‘Response.Redirect’ for redirection and redirect this page to Contact Page. Following is a html code for that button.

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Click me to redirect" />

And following is a code click event handler for click event of above button.

protected void Button1_Click(object sender, EventArgs e)
{
    Response.Redirect("Contact");
}

That’s it. You are done.

Right now you are on about us page like following.

AboutUs-RedirectionASP.NETFriendlyURLs

Now once you click ‘Click me to redirect’,It will load contact page.

Contact-ASP.NETFriendlyURLsRedirection

That’s it. Hope you like it. Stay tuned for more!!

Shout it

kick it on DotNetKicks.com

1 comment:

  1. It's the season of love and everyone is busy planning special ways to make their Valentine's Day memorable. Check out personalized photo calendars & t-shirts on http://www.facebook.com/Vistap... that will have your special one appreciating
    your thoughtfulness. And if you like our FB page, consider a Flat 25% OFF as our Valentine's gift to you.

    ReplyDelete

Your feedback are very important to me. Please provide your feedback via putting comments.