|
-
Feb 24th, 2004, 09:40 AM
#1
Thread Starter
Frenzied Member
Vanity URLs
I'm using Application_BeginRequest within the global.asax file to rewrite URLs on the fly.
Examples:
http://192.168.14.30/clients/design/imex/test.aspx
becomes
http://192.168.14.30/browse.aspx?path=/design/imex/test
but
http://192.168.14.30/default.aspx
still goes to
http://192.168.14.30/default.aspx
The code used is as follows:
Code:
<%@ Language="C#" %>
<%@ Import Namespace="System.IO" %>
<script runat=server>
void Application_BeginRequest(Object sender , EventArgs e)
{
string strClientPath;
string strCustomPath;
if ( Request.Path.ToLower().IndexOf("clients" ) != -1 ) {
strClientPath = Request.Path.Replace( ".aspx", "" );
strClientPath = strClientPath.Replace( "/clients", "");
strCustomPath = string .Format( "/browse.aspx?path={0}", strClientPath );
Context.RewritePath( strCustomPath );
}
}
</Script>
I would like to have a URL like: http://192.168.14.30/clients/design/imex/test also map to http://192.168.14.30/browse.aspx?path=/design/imex/test but as a aspx file is not specified IIS tries to redirect to http://192.168.14.30/clients/design/...t/default.aspx and I get a 404 error. Is there any way of getting around this?
DJ
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|