1

I created a aspx blog website which creates a page dynamically.At the time of page creation
the unique id automatically generated it's name was generated as given below

eg:

http://www.websitename.com/2016/f1.aspx

http://www.websitename.com/2016/f2.aspx

http://www.websitename.com/2016/f3.aspx

How can I change the url name of the page.

Ex:(websitename.com/2016/f2.aspx to websitename.com/2016/helloworld.aspx)

helloworld.aspx is the blog title which I've consider to given against f2.aspx. How can I replace programmatically in C# code?

5
  • Response.Redirect("url") should work. Commented Aug 27, 2016 at 11:54
  • sir u mistaken i just want to rewrite the url . The following example that i was given above.Anyway thanks for your compliment... Commented Aug 27, 2016 at 12:09
  • 1
    are you starting with a string and getting a string out, or are you starting with something like a HttpContext? There are lots of ways to work with a URL depending on where you come in from. e.g. MVC does a whole thing with RouteValues, in RequestContext you can see the URL.HostName. Theres too much to cover everything in a quick reply. If you are just dealing with strings, then maybe something like a string.Split('/'); then deal with array index 2 and join the array back together. Commented Aug 27, 2016 at 12:23
  • @keerthiraaju I guess you don't want to use javascript to do it ? Commented Aug 27, 2016 at 12:25
  • See weblogs.asp.net/scottgu/tip-trick-url-rewriting-with-asp-net Commented Aug 30, 2016 at 12:58

1 Answer 1

1

Yes,

You can do this: websitename.com/2016/helloworld.aspx.

You'll need to add either a different parameter to identify f1, f2 or f3 like websitename.com/2016/helloworld.aspx?PageId= f1 or, you can use URL like websitename.com/2016/helloworld.aspx/f1 or websitename.com/2016/helloworld.aspx/f2

Now , to achieve this (if you are using ASP.NET) need to write HTTP handler or can work in Global.asax as well.

Below links will help you more:

  1. C-SharpCorner: URL Rewriting
  2. Codeproject: URL Rewriting
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.