Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > rewriting URL

Reply
Thread Tools

rewriting URL

 
 
Christina
Guest
Posts: n/a
 
      11-16-2006
Hiya!!

I am trying to do something really simple here..

I have a link, clicking on which leads to a page say MyPage.aspx.
There's a query string also passed to it. Hence its :

http://machineName/projName/MyPage.aspx?myQueryStr=abcd

Now, I dont want this to be displayed to the user. I want something
like:
http://machineName/projName/MyPage,
on anything, but NOT the querystring.

I tried the below code :

1)
In global.asax.vb :

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As
EventArgs)
Dim strCurrentPath As String
Dim strCustomPath As String

strCurrentPath = Request.Path
strCurrentPath = strCurrentPath.ToLower()
If (strCurrentPath.IndexOf("/MyPage.aspx") > -1) Then

strCustomPath = "http://machineName/projName/MyPage"

Context.RewritePath(strCustomPath)
End If

The above code gives an error : Invalid file name for monitoring..

2)
In page_load of mypage.aspx
Context.RewritePath(strCustomPath)

Still the same error

Any pointers ?

Thanks!!

 
Reply With Quote
 
 
 
 
Mark Fitzpatrick
Guest
Posts: n/a
 
      11-16-2006
ASP.Net 2.0 has this built right in. What you'll want is the urlmapping
section of the config file (if I remember correctly). There's also a really
nice utility at http://www.urlrewriting.net that can do more extensive
mapping with regular expressions.

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Christina" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hiya!!
>
> I am trying to do something really simple here..
>
> I have a link, clicking on which leads to a page say MyPage.aspx.
> There's a query string also passed to it. Hence its :
>
> http://machineName/projName/MyPage.aspx?myQueryStr=abcd
>
> Now, I dont want this to be displayed to the user. I want something
> like:
> http://machineName/projName/MyPage,
> on anything, but NOT the querystring.
>
> I tried the below code :
>
> 1)
> In global.asax.vb :
>
> Sub Application_BeginRequest(ByVal sender As Object, ByVal e As
> EventArgs)
> Dim strCurrentPath As String
> Dim strCustomPath As String
>
> strCurrentPath = Request.Path
> strCurrentPath = strCurrentPath.ToLower()
> If (strCurrentPath.IndexOf("/MyPage.aspx") > -1) Then
>
> strCustomPath = "http://machineName/projName/MyPage"
>
> Context.RewritePath(strCustomPath)
> End If
>
> The above code gives an error : Invalid file name for monitoring..
>
> 2)
> In page_load of mypage.aspx
> Context.RewritePath(strCustomPath)
>
> Still the same error
>
> Any pointers ?
>
> Thanks!!
>



 
Reply With Quote
 
 
 
 
kferron
Guest
Posts: n/a
 
      11-17-2006
I don't think this is what she is asking, although urlmapping would
work for say, http://machineName/projName/MyPage.aspx (if you want
asp.net to handle files with no extension, this is a webserver setting
that has to handle the request first), you could map:


http://machineName/projName/MyPage.aspx

to

http://machineName/projName/MyPage.aspx?myQueryStr=abcd

you could not say, have MyPage.aspx also map to:

http://machineName/projName/MyPage.aspx?myQueryStr=1234

so the issue is moot.

Basically you could

a) have a different url mapping for every possible querystring
possibility (eg. MyPageAbcd.aspx -> MyPage.aspx?myQueryStr=abcd)

b) create a httphandler that takes advantage of Request.RewritePath()
that allows you to parse a request and rewrite the url to the correct
querystring (eg. http://machineName/projName/MyPage/abcd.aspx) and then
map that in your handler to ->
http://machineName/projName/MyPage.aspx?myQueryStr=abcd by parsing
http://machineName/projName/<aspxpage>/<querystringvalue>.aspx. This
option is really limitless, as long as you know how to parse the
incoming url.

c) your third option isn't as flexible, but requires no url rewriting,
and that is to post all of your data instead of passing in querystring



~kcf


Mark Fitzpatrick wrote:
> ASP.Net 2.0 has this built right in. What you'll want is the urlmapping
> section of the config file (if I remember correctly). There's also a really
> nice utility at http://www.urlrewriting.net that can do more extensive
> mapping with regular expressions.
>
> --
> Hope this helps,
> Mark Fitzpatrick
> Former Microsoft FrontPage MVP 199?-2006
>
> "Christina" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
> > Hiya!!
> >
> > I am trying to do something really simple here..
> >
> > I have a link, clicking on which leads to a page say MyPage.aspx.
> > There's a query string also passed to it. Hence its :
> >
> > http://machineName/projName/MyPage.aspx?myQueryStr=abcd
> >
> > Now, I dont want this to be displayed to the user. I want something
> > like:
> > http://machineName/projName/MyPage,
> > on anything, but NOT the querystring.
> >
> > I tried the below code :
> >
> > 1)
> > In global.asax.vb :
> >
> > Sub Application_BeginRequest(ByVal sender As Object, ByVal e As
> > EventArgs)
> > Dim strCurrentPath As String
> > Dim strCustomPath As String
> >
> > strCurrentPath = Request.Path
> > strCurrentPath = strCurrentPath.ToLower()
> > If (strCurrentPath.IndexOf("/MyPage.aspx") > -1) Then
> >
> > strCustomPath = "http://machineName/projName/MyPage"
> >
> > Context.RewritePath(strCustomPath)
> > End If
> >
> > The above code gives an error : Invalid file name for monitoring..
> >
> > 2)
> > In page_load of mypage.aspx
> > Context.RewritePath(strCustomPath)
> >
> > Still the same error
> >
> > Any pointers ?
> >
> > Thanks!!
> >


 
Reply With Quote
 
Christina
Guest
Posts: n/a
 
      11-17-2006
Hmmm.... doesnt seem to be as simple as I thought it would be.

As kferron said, I'll focus on : httphandler -> rewrite path ->
parsing..

Meanwhile, if anybody has a link which shows how to do this, or a code
snippet, that would be great!!

Thanks for the help!!


kferron wrote:
> I don't think this is what she is asking, although urlmapping would
> work for say, http://machineName/projName/MyPage.aspx (if you want
> asp.net to handle files with no extension, this is a webserver setting
> that has to handle the request first), you could map:
>
>
> http://machineName/projName/MyPage.aspx
>
> to
>
> http://machineName/projName/MyPage.aspx?myQueryStr=abcd
>
> you could not say, have MyPage.aspx also map to:
>
> http://machineName/projName/MyPage.aspx?myQueryStr=1234
>
> so the issue is moot.
>
> Basically you could
>
> a) have a different url mapping for every possible querystring
> possibility (eg. MyPageAbcd.aspx -> MyPage.aspx?myQueryStr=abcd)
>
> b) create a httphandler that takes advantage of Request.RewritePath()
> that allows you to parse a request and rewrite the url to the correct
> querystring (eg. http://machineName/projName/MyPage/abcd.aspx) and then
> map that in your handler to ->
> http://machineName/projName/MyPage.aspx?myQueryStr=abcd by parsing
> http://machineName/projName/<aspxpage>/<querystringvalue>.aspx. This
> option is really limitless, as long as you know how to parse the
> incoming url.
>
> c) your third option isn't as flexible, but requires no url rewriting,
> and that is to post all of your data instead of passing in querystring
>
>
>
> ~kcf
>
>
> Mark Fitzpatrick wrote:
> > ASP.Net 2.0 has this built right in. What you'll want is the urlmapping
> > section of the config file (if I remember correctly). There's also a really
> > nice utility at http://www.urlrewriting.net that can do more extensive
> > mapping with regular expressions.
> >
> > --
> > Hope this helps,
> > Mark Fitzpatrick
> > Former Microsoft FrontPage MVP 199?-2006
> >
> > "Christina" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) ups.com...
> > > Hiya!!
> > >
> > > I am trying to do something really simple here..
> > >
> > > I have a link, clicking on which leads to a page say MyPage.aspx.
> > > There's a query string also passed to it. Hence its :
> > >
> > > http://machineName/projName/MyPage.aspx?myQueryStr=abcd
> > >
> > > Now, I dont want this to be displayed to the user. I want something
> > > like:
> > > http://machineName/projName/MyPage,
> > > on anything, but NOT the querystring.
> > >
> > > I tried the below code :
> > >
> > > 1)
> > > In global.asax.vb :
> > >
> > > Sub Application_BeginRequest(ByVal sender As Object, ByVal e As
> > > EventArgs)
> > > Dim strCurrentPath As String
> > > Dim strCustomPath As String
> > >
> > > strCurrentPath = Request.Path
> > > strCurrentPath = strCurrentPath.ToLower()
> > > If (strCurrentPath.IndexOf("/MyPage.aspx") > -1) Then
> > >
> > > strCustomPath = "http://machineName/projName/MyPage"
> > >
> > > Context.RewritePath(strCustomPath)
> > > End If
> > >
> > > The above code gives an error : Invalid file name for monitoring..
> > >
> > > 2)
> > > In page_load of mypage.aspx
> > > Context.RewritePath(strCustomPath)
> > >
> > > Still the same error
> > >
> > > Any pointers ?
> > >
> > > Thanks!!
> > >


 
Reply With Quote
 
kferron
Guest
Posts: n/a
 
      11-17-2006

this is a pretty cool approach in my opinion Christina

http://www.codeproject.com/aspnet/urlrewriter.asp



Christina wrote:
> Hmmm.... doesnt seem to be as simple as I thought it would be.
>
> As kferron said, I'll focus on : httphandler -> rewrite path ->
> parsing..
>
> Meanwhile, if anybody has a link which shows how to do this, or a code
> snippet, that would be great!!
>
> Thanks for the help!!
>
>
> kferron wrote:
> > I don't think this is what she is asking, although urlmapping would
> > work for say, http://machineName/projName/MyPage.aspx (if you want
> > asp.net to handle files with no extension, this is a webserver setting
> > that has to handle the request first), you could map:
> >
> >
> > http://machineName/projName/MyPage.aspx
> >
> > to
> >
> > http://machineName/projName/MyPage.aspx?myQueryStr=abcd
> >
> > you could not say, have MyPage.aspx also map to:
> >
> > http://machineName/projName/MyPage.aspx?myQueryStr=1234
> >
> > so the issue is moot.
> >
> > Basically you could
> >
> > a) have a different url mapping for every possible querystring
> > possibility (eg. MyPageAbcd.aspx -> MyPage.aspx?myQueryStr=abcd)
> >
> > b) create a httphandler that takes advantage of Request.RewritePath()
> > that allows you to parse a request and rewrite the url to the correct
> > querystring (eg. http://machineName/projName/MyPage/abcd.aspx) and then
> > map that in your handler to ->
> > http://machineName/projName/MyPage.aspx?myQueryStr=abcd by parsing
> > http://machineName/projName/<aspxpage>/<querystringvalue>.aspx. This
> > option is really limitless, as long as you know how to parse the
> > incoming url.
> >
> > c) your third option isn't as flexible, but requires no url rewriting,
> > and that is to post all of your data instead of passing in querystring
> >
> >
> >
> > ~kcf
> >
> >
> > Mark Fitzpatrick wrote:
> > > ASP.Net 2.0 has this built right in. What you'll want is the urlmapping
> > > section of the config file (if I remember correctly). There's also a really
> > > nice utility at http://www.urlrewriting.net that can do more extensive
> > > mapping with regular expressions.
> > >
> > > --
> > > Hope this helps,
> > > Mark Fitzpatrick
> > > Former Microsoft FrontPage MVP 199?-2006
> > >
> > > "Christina" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed) ups.com...
> > > > Hiya!!
> > > >
> > > > I am trying to do something really simple here..
> > > >
> > > > I have a link, clicking on which leads to a page say MyPage.aspx.
> > > > There's a query string also passed to it. Hence its :
> > > >
> > > > http://machineName/projName/MyPage.aspx?myQueryStr=abcd
> > > >
> > > > Now, I dont want this to be displayed to the user. I want something
> > > > like:
> > > > http://machineName/projName/MyPage,
> > > > on anything, but NOT the querystring.
> > > >
> > > > I tried the below code :
> > > >
> > > > 1)
> > > > In global.asax.vb :
> > > >
> > > > Sub Application_BeginRequest(ByVal sender As Object, ByVal e As
> > > > EventArgs)
> > > > Dim strCurrentPath As String
> > > > Dim strCustomPath As String
> > > >
> > > > strCurrentPath = Request.Path
> > > > strCurrentPath = strCurrentPath.ToLower()
> > > > If (strCurrentPath.IndexOf("/MyPage.aspx") > -1) Then
> > > >
> > > > strCustomPath = "http://machineName/projName/MyPage"
> > > >
> > > > Context.RewritePath(strCustomPath)
> > > > End If
> > > >
> > > > The above code gives an error : Invalid file name for monitoring..
> > > >
> > > > 2)
> > > > In page_load of mypage.aspx
> > > > Context.RewritePath(strCustomPath)
> > > >
> > > > Still the same error
> > > >
> > > > Any pointers ?
> > > >
> > > > Thanks!!
> > > >


 
Reply With Quote
 
Christina
Guest
Posts: n/a
 
      11-17-2006
Thanks !!
I will implement it and let you know how'd it go..


kferron wrote:
> this is a pretty cool approach in my opinion Christina
>
> http://www.codeproject.com/aspnet/urlrewriter.asp
>
>
>
> Christina wrote:
> > Hmmm.... doesnt seem to be as simple as I thought it would be.
> >
> > As kferron said, I'll focus on : httphandler -> rewrite path ->
> > parsing..
> >
> > Meanwhile, if anybody has a link which shows how to do this, or a code
> > snippet, that would be great!!
> >
> > Thanks for the help!!
> >
> >
> > kferron wrote:
> > > I don't think this is what she is asking, although urlmapping would
> > > work for say, http://machineName/projName/MyPage.aspx (if you want
> > > asp.net to handle files with no extension, this is a webserver setting
> > > that has to handle the request first), you could map:
> > >
> > >
> > > http://machineName/projName/MyPage.aspx
> > >
> > > to
> > >
> > > http://machineName/projName/MyPage.aspx?myQueryStr=abcd
> > >
> > > you could not say, have MyPage.aspx also map to:
> > >
> > > http://machineName/projName/MyPage.aspx?myQueryStr=1234
> > >
> > > so the issue is moot.
> > >
> > > Basically you could
> > >
> > > a) have a different url mapping for every possible querystring
> > > possibility (eg. MyPageAbcd.aspx -> MyPage.aspx?myQueryStr=abcd)
> > >
> > > b) create a httphandler that takes advantage of Request.RewritePath()
> > > that allows you to parse a request and rewrite the url to the correct
> > > querystring (eg. http://machineName/projName/MyPage/abcd.aspx) and then
> > > map that in your handler to ->
> > > http://machineName/projName/MyPage.aspx?myQueryStr=abcd by parsing
> > > http://machineName/projName/<aspxpage>/<querystringvalue>.aspx. This
> > > option is really limitless, as long as you know how to parse the
> > > incoming url.
> > >
> > > c) your third option isn't as flexible, but requires no url rewriting,
> > > and that is to post all of your data instead of passing in querystring
> > >
> > >
> > >
> > > ~kcf
> > >
> > >
> > > Mark Fitzpatrick wrote:
> > > > ASP.Net 2.0 has this built right in. What you'll want is the urlmapping
> > > > section of the config file (if I remember correctly). There's also a really
> > > > nice utility at http://www.urlrewriting.net that can do more extensive
> > > > mapping with regular expressions.
> > > >
> > > > --
> > > > Hope this helps,
> > > > Mark Fitzpatrick
> > > > Former Microsoft FrontPage MVP 199?-2006
> > > >
> > > > "Christina" <(E-Mail Removed)> wrote in message
> > > > news:(E-Mail Removed) ups.com...
> > > > > Hiya!!
> > > > >
> > > > > I am trying to do something really simple here..
> > > > >
> > > > > I have a link, clicking on which leads to a page say MyPage.aspx.
> > > > > There's a query string also passed to it. Hence its :
> > > > >
> > > > > http://machineName/projName/MyPage.aspx?myQueryStr=abcd
> > > > >
> > > > > Now, I dont want this to be displayed to the user. I want something
> > > > > like:
> > > > > http://machineName/projName/MyPage,
> > > > > on anything, but NOT the querystring.
> > > > >
> > > > > I tried the below code :
> > > > >
> > > > > 1)
> > > > > In global.asax.vb :
> > > > >
> > > > > Sub Application_BeginRequest(ByVal sender As Object, ByVal e As
> > > > > EventArgs)
> > > > > Dim strCurrentPath As String
> > > > > Dim strCustomPath As String
> > > > >
> > > > > strCurrentPath = Request.Path
> > > > > strCurrentPath = strCurrentPath.ToLower()
> > > > > If (strCurrentPath.IndexOf("/MyPage.aspx") > -1) Then
> > > > >
> > > > > strCustomPath = "http://machineName/projName/MyPage"
> > > > >
> > > > > Context.RewritePath(strCustomPath)
> > > > > End If
> > > > >
> > > > > The above code gives an error : Invalid file name for monitoring..
> > > > >
> > > > > 2)
> > > > > In page_load of mypage.aspx
> > > > > Context.RewritePath(strCustomPath)
> > > > >
> > > > > Still the same error
> > > > >
> > > > > Any pointers ?
> > > > >
> > > > > Thanks!!
> > > > >


 
Reply With Quote
 
Christina
Guest
Posts: n/a
 
      11-17-2006
Hey, I would like to consider the third approach also:
post all of your data instead of passing in querystring

Can I get a pointer to that too..

Thanx!!


kferron wrote:
> this is a pretty cool approach in my opinion Christina
>
> http://www.codeproject.com/aspnet/urlrewriter.asp
>
>
>
> Christina wrote:
> > Hmmm.... doesnt seem to be as simple as I thought it would be.
> >
> > As kferron said, I'll focus on : httphandler -> rewrite path ->
> > parsing..
> >
> > Meanwhile, if anybody has a link which shows how to do this, or a code
> > snippet, that would be great!!
> >
> > Thanks for the help!!
> >
> >
> > kferron wrote:
> > > I don't think this is what she is asking, although urlmapping would
> > > work for say, http://machineName/projName/MyPage.aspx (if you want
> > > asp.net to handle files with no extension, this is a webserver setting
> > > that has to handle the request first), you could map:
> > >
> > >
> > > http://machineName/projName/MyPage.aspx
> > >
> > > to
> > >
> > > http://machineName/projName/MyPage.aspx?myQueryStr=abcd
> > >
> > > you could not say, have MyPage.aspx also map to:
> > >
> > > http://machineName/projName/MyPage.aspx?myQueryStr=1234
> > >
> > > so the issue is moot.
> > >
> > > Basically you could
> > >
> > > a) have a different url mapping for every possible querystring
> > > possibility (eg. MyPageAbcd.aspx -> MyPage.aspx?myQueryStr=abcd)
> > >
> > > b) create a httphandler that takes advantage of Request.RewritePath()
> > > that allows you to parse a request and rewrite the url to the correct
> > > querystring (eg. http://machineName/projName/MyPage/abcd.aspx) and then
> > > map that in your handler to ->
> > > http://machineName/projName/MyPage.aspx?myQueryStr=abcd by parsing
> > > http://machineName/projName/<aspxpage>/<querystringvalue>.aspx. This
> > > option is really limitless, as long as you know how to parse the
> > > incoming url.
> > >
> > > c) your third option isn't as flexible, but requires no url rewriting,
> > > and that is to post all of your data instead of passing in querystring
> > >
> > >
> > >
> > > ~kcf
> > >
> > >
> > > Mark Fitzpatrick wrote:
> > > > ASP.Net 2.0 has this built right in. What you'll want is the urlmapping
> > > > section of the config file (if I remember correctly). There's also a really
> > > > nice utility at http://www.urlrewriting.net that can do more extensive
> > > > mapping with regular expressions.
> > > >
> > > > --
> > > > Hope this helps,
> > > > Mark Fitzpatrick
> > > > Former Microsoft FrontPage MVP 199?-2006
> > > >
> > > > "Christina" <(E-Mail Removed)> wrote in message
> > > > news:(E-Mail Removed) ups.com...
> > > > > Hiya!!
> > > > >
> > > > > I am trying to do something really simple here..
> > > > >
> > > > > I have a link, clicking on which leads to a page say MyPage.aspx.
> > > > > There's a query string also passed to it. Hence its :
> > > > >
> > > > > http://machineName/projName/MyPage.aspx?myQueryStr=abcd
> > > > >
> > > > > Now, I dont want this to be displayed to the user. I want something
> > > > > like:
> > > > > http://machineName/projName/MyPage,
> > > > > on anything, but NOT the querystring.
> > > > >
> > > > > I tried the below code :
> > > > >
> > > > > 1)
> > > > > In global.asax.vb :
> > > > >
> > > > > Sub Application_BeginRequest(ByVal sender As Object, ByVal e As
> > > > > EventArgs)
> > > > > Dim strCurrentPath As String
> > > > > Dim strCustomPath As String
> > > > >
> > > > > strCurrentPath = Request.Path
> > > > > strCurrentPath = strCurrentPath.ToLower()
> > > > > If (strCurrentPath.IndexOf("/MyPage.aspx") > -1) Then
> > > > >
> > > > > strCustomPath = "http://machineName/projName/MyPage"
> > > > >
> > > > > Context.RewritePath(strCustomPath)
> > > > > End If
> > > > >
> > > > > The above code gives an error : Invalid file name for monitoring..
> > > > >
> > > > > 2)
> > > > > In page_load of mypage.aspx
> > > > > Context.RewritePath(strCustomPath)
> > > > >
> > > > > Still the same error
> > > > >
> > > > > Any pointers ?
> > > > >
> > > > > Thanks!!
> > > > >


 
Reply With Quote
 
Christina
Guest
Posts: n/a
 
      11-18-2006
I tried to used HTTPModule:

In the Application_BeginRequest, after checkin the URL, ie if its
/myFolder/URL.aspx, then i am using
HttpContext.Current.RewritePath("/myFolder/newURL.aspx") to rewrite the
URL.

Now, this is the result:
I type http://MachineName/myFolder/URL.apx,
it displays the page - newURL.aspx (but in the addressbar, its
http://MachineName/myFolder/URL.apx).

I wanted it to be other way round, ie
I type http://MachineName/myFolder/URL.apx,
it displays the page - URL.aspx (but changes the url in the addressbar
to - http://MachineName/myFolder/newURL.apx).

The reason is, my orignal link has a querystring attached to it. Now I
dont want the user to see the query string. So I want the page to be
displayed as it would have (with the querystring), but want to display
the URL without the querystring. I wanted to rewrite just my Url (in
the addressbar) to the same url(but without query string).

Any idea ??

Thanks!!

Christina wrote:
> Hey, I would like to consider the third approach also:
> post all of your data instead of passing in querystring
>
> Can I get a pointer to that too..
>
> Thanx!!
>
>
> kferron wrote:
> > this is a pretty cool approach in my opinion Christina
> >
> > http://www.codeproject.com/aspnet/urlrewriter.asp
> >
> >
> >
> > Christina wrote:
> > > Hmmm.... doesnt seem to be as simple as I thought it would be.
> > >
> > > As kferron said, I'll focus on : httphandler -> rewrite path ->
> > > parsing..
> > >
> > > Meanwhile, if anybody has a link which shows how to do this, or a code
> > > snippet, that would be great!!
> > >
> > > Thanks for the help!!
> > >
> > >
> > > kferron wrote:
> > > > I don't think this is what she is asking, although urlmapping would
> > > > work for say, http://machineName/projName/MyPage.aspx (if you want
> > > > asp.net to handle files with no extension, this is a webserver setting
> > > > that has to handle the request first), you could map:
> > > >
> > > >
> > > > http://machineName/projName/MyPage.aspx
> > > >
> > > > to
> > > >
> > > > http://machineName/projName/MyPage.aspx?myQueryStr=abcd
> > > >
> > > > you could not say, have MyPage.aspx also map to:
> > > >
> > > > http://machineName/projName/MyPage.aspx?myQueryStr=1234
> > > >
> > > > so the issue is moot.
> > > >
> > > > Basically you could
> > > >
> > > > a) have a different url mapping for every possible querystring
> > > > possibility (eg. MyPageAbcd.aspx -> MyPage.aspx?myQueryStr=abcd)
> > > >
> > > > b) create a httphandler that takes advantage of Request.RewritePath()
> > > > that allows you to parse a request and rewrite the url to the correct
> > > > querystring (eg. http://machineName/projName/MyPage/abcd.aspx) and then
> > > > map that in your handler to ->
> > > > http://machineName/projName/MyPage.aspx?myQueryStr=abcd by parsing
> > > > http://machineName/projName/<aspxpage>/<querystringvalue>.aspx. This
> > > > option is really limitless, as long as you know how to parse the
> > > > incoming url.
> > > >
> > > > c) your third option isn't as flexible, but requires no url rewriting,
> > > > and that is to post all of your data instead of passing in querystring
> > > >
> > > >
> > > >
> > > > ~kcf
> > > >
> > > >
> > > > Mark Fitzpatrick wrote:
> > > > > ASP.Net 2.0 has this built right in. What you'll want is the urlmapping
> > > > > section of the config file (if I remember correctly). There's also a really
> > > > > nice utility at http://www.urlrewriting.net that can do more extensive
> > > > > mapping with regular expressions.
> > > > >
> > > > > --
> > > > > Hope this helps,
> > > > > Mark Fitzpatrick
> > > > > Former Microsoft FrontPage MVP 199?-2006
> > > > >
> > > > > "Christina" <(E-Mail Removed)> wrote in message
> > > > > news:(E-Mail Removed) ups.com...
> > > > > > Hiya!!
> > > > > >
> > > > > > I am trying to do something really simple here..
> > > > > >
> > > > > > I have a link, clicking on which leads to a page say MyPage.aspx.
> > > > > > There's a query string also passed to it. Hence its :
> > > > > >
> > > > > > http://machineName/projName/MyPage.aspx?myQueryStr=abcd
> > > > > >
> > > > > > Now, I dont want this to be displayed to the user. I want something
> > > > > > like:
> > > > > > http://machineName/projName/MyPage,
> > > > > > on anything, but NOT the querystring.
> > > > > >
> > > > > > I tried the below code :
> > > > > >
> > > > > > 1)
> > > > > > In global.asax.vb :
> > > > > >
> > > > > > Sub Application_BeginRequest(ByVal sender As Object, ByVal e As
> > > > > > EventArgs)
> > > > > > Dim strCurrentPath As String
> > > > > > Dim strCustomPath As String
> > > > > >
> > > > > > strCurrentPath = Request.Path
> > > > > > strCurrentPath = strCurrentPath.ToLower()
> > > > > > If (strCurrentPath.IndexOf("/MyPage.aspx") > -1) Then
> > > > > >
> > > > > > strCustomPath = "http://machineName/projName/MyPage"
> > > > > >
> > > > > > Context.RewritePath(strCustomPath)
> > > > > > End If
> > > > > >
> > > > > > The above code gives an error : Invalid file name for monitoring..
> > > > > >
> > > > > > 2)
> > > > > > In page_load of mypage.aspx
> > > > > > Context.RewritePath(strCustomPath)
> > > > > >
> > > > > > Still the same error
> > > > > >
> > > > > > Any pointers ?
> > > > > >
> > > > > > Thanks!!
> > > > > >


 
Reply With Quote
 
Holger Boskugel
Guest
Posts: n/a
 
      11-19-2006
Hello Christina

> In the Application_BeginRequest, after checkin the URL, ie if its
> /myFolder/URL.aspx, then i am using
> HttpContext.Current.RewritePath("/myFolder/newURL.aspx") to rewrite the
> URL.
>
> Now, this is the result:
> I type http://MachineName/myFolder/URL.apx,
> it displays the page - newURL.aspx (but in the addressbar, its
> http://MachineName/myFolder/URL.apx).
>
> I wanted it to be other way round, ie
> I type http://MachineName/myFolder/URL.apx,
> it displays the page - URL.aspx (but changes the url in the addressbar
> to - http://MachineName/myFolder/newURL.apx).
>
> The reason is, my orignal link has a querystring attached to it. Now I
> dont want the user to see the query string. So I want the page to be
> displayed as it would have (with the querystring), but want to display
> the URL without the querystring. I wanted to rewrite just my Url (in
> the addressbar) to the same url(but without query string).
>
> Any idea ??


put the Query data in you session an make a redirect to the URL you
want and then pick up the Query from your Session.


Regards

Holger


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
url rewriting with no extension in url =?Utf-8?B?cmFwaWRkYXRh?= ASP .Net 8 11-02-2006 01:48 PM
URL rewriting on the Cisco Content Switch CSS 11503 j208@gmx.net Cisco 1 10-02-2005 06:35 PM
url rewriting when the url contains parameters Gaurav Agarwal Java 2 01-31-2005 11:15 AM
URL rewriting with SCA -=_ Antani _=- Cisco 0 09-16-2004 08:45 AM
URL rewriting Juha Borenius ASP .Net 2 08-15-2003 01:40 PM



Advertisments