what is the url rewriting?how to rewrite the url? give any
example
Answer / chinnu
If you don't like having meaningless URL's for your
visitors (i.e index.aspx?id=3&pid=3932), consider URL Re-
writing. With URL rewriting, you can store all your content
in the database while having user-friendly URL's. Here's a
code snippet to do just this:
void Application_BeginRequest(Object sender, EventArgs e)
{
String strCurrentPath;
String strCustomPath;
strCurrentPath = Request.Path;
strCurrentPath = strCurrentPath.ToLower();
// the URL contains this folder name
if (strCurrentPath.IndexOf( "/SomeSubFolder/" ) > -1)
{
strCustomPath = "getContent.aspx?id=" +
Path.GetFileNameWithoutExtension( strCurrentPath );
// rewrite the URL
Context.RewritePath( strCustomPath );
}
}
The getContent.aspx will take the page name as a parameter
and do a lookup in the database and return the content for
the page. I have left the details out because the point of
the code snippet is to show how to rewrite the URL and get
the data from the database.
| Is This Answer Correct ? | 0 Yes | 2 No |
What is crypt () in php?
how to count how many sundays in month?
How do I get csrf token?
What is the difference between urlencode and urldecode ?
How can we access the data sent through the url with the get method?
Explain how we can get the number of elements in an array?
What is escaping to php?
What is a procedure in php?
Write a select query that will be displayed the duplicated site name and how many times it is duplicated?
Name some of the constants in php and their purpose.
Is php closing tag necessary?
how to upload more than 50 mb? i tried but session was expired....certain time .....i was set session duration three days .... how to rectified? if any one know that post ur answer as soon as possible?already i was increase php.ini but not working......