RE: Forcing browser to reload the "same page" with "mapped URL"

RE: Forcing browser to reload the "same page" with "mapped URL"

am 30.03.2008 01:42:00 von pbromberg

Can you post a "Short but complete" code sample that illustrates your issue?

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net


"Willy" wrote:

> I have a website that uses querystrings on a certain page to show multiple
> contents.
> I have created mapped pages to hide the gory details of these querystrings.
>
> So instead of details.aspx?ID=kldjlkdjldsjlkds&cat=jjfjfj
> the client sees products.aspx
>
> I also use these "mapped" pages in my sitemap file.
>
> This site is multilingual so I have buttons on the page to switch languages.
> The switch works except that the thing insists on going to
> details.aspx?ID=kldjlkdjldsjlkds&cat=jjfjfj instead of products.aspx. This
> spoils the breadcrumbs that are linked to the sitemap file.
>
> The code I use is as simple as :
> Me.Page.Response.Redirect(Me.Page.Request.RawUrl.ToString, True)
> (rawurl contains products.aspx)
> Can somebody tell me what I am doing wrong ?
>
> Thanks a lot.
>

Re: Forcing browser to reload the "same page" with "mapped URL"

am 30.03.2008 11:14:27 von Willy

web.config:

....







default.aspx:
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Server.Transfer(Me.Request.RawUrl)
End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button2.Click
Response.Redirect(Me.Request.RawUrl, False)
End Sub

Protected Sub Button2_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button2.Load
Button2.Text = "redirect " & Me.Request.RawUrl
End Sub
End Class

Now I visit the page jake.aspx (which doesn't exist : it is a mapped file).
My browser shows Jake.aspx
I click any of the buttons to "refresh" the current page (I change the
language of the current thread in the meantime).
My browser shows Default.aspx. But I want it to be jake.aspx

"Peter Bromberg [C# MVP]" wrote in message
news:4D0B7345-2C55-45B1-8C26-D6514D5A2A0D@microsoft.com...
> Can you post a "Short but complete" code sample that illustrates your
> issue?
>
> -- Peter
> Site: http://www.eggheadcafe.com
> UnBlog: http://petesbloggerama.blogspot.com
> Short Urls & more: http://ittyurl.net
>
>
> "Willy" wrote:
>
>> I have a website that uses querystrings on a certain page to show
>> multiple
>> contents.
>> I have created mapped pages to hide the gory details of these
>> querystrings.
>>
>> So instead of details.aspx?ID=kldjlkdjldsjlkds&cat=jjfjfj
>> the client sees products.aspx
>>
>> I also use these "mapped" pages in my sitemap file.
>>
>> This site is multilingual so I have buttons on the page to switch
>> languages.
>> The switch works except that the thing insists on going to
>> details.aspx?ID=kldjlkdjldsjlkds&cat=jjfjfj instead of products.aspx.
>> This
>> spoils the breadcrumbs that are linked to the sitemap file.
>>
>> The code I use is as simple as :
>> Me.Page.Response.Redirect(Me.Page.Request.RawUrl.ToString,
>> True)
>> (rawurl contains products.aspx)
>> Can somebody tell me what I am doing wrong ?
>>
>> Thanks a lot.
>>

Re: Forcing browser to reload the "same page" with "mapped URL"

am 01.04.2008 23:08:52 von Willy

So ? I posted a sample, didn't I?

> web.config:
>
> ...
>
>
>
>

>

>
>
> default.aspx:
> Partial Class _Default
> Inherits System.Web.UI.Page
>
> Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> Server.Transfer(Me.Request.RawUrl)
> End Sub
>
> Protected Sub Button2_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button2.Click
> Response.Redirect(Me.Request.RawUrl, False)
> End Sub
>
> Protected Sub Button2_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button2.Load
> Button2.Text = "redirect " & Me.Request.RawUrl
> End Sub
> End Class
>
> Now I visit the page jake.aspx (which doesn't exist : it is a mapped
> file).
> My browser shows Jake.aspx
> I click any of the buttons to "refresh" the current page (I change the
> language of the current thread in the meantime).
> My browser shows Default.aspx. But I want it to be jake.aspx
>

Re: Forcing browser to reload the "same page" with "mapped URL"

am 02.04.2008 15:54:21 von George Ter-Saakov

It's a common problem with URL rewriting.
I am not sure how works. I always did my own custom URL
rewrite... So you will have to dig a little to find a remedy.

but here is the problem...

tag in asp.net pages have an action set. And it's set to current
page.
So when url rewriting happens browser hits "/jake.aspx", url rewriting
rewrites it to "/default.aspx" and makes ASP.NET think that it hit
"/default.aspx"

But action property of the has "/deault.aspx" cause ASP.NET thinks
that browser hit "/default.aspx", So as sson as you press the any button on
the form browser hits "/default.aspx" with a postback..

So here is the possible solutions...

1. make your own MyHtmlForm class that derived from HtmlForm and suppress
action property when outputting to browser
check out this article
http://www.codeproject.com/KB/aspnet/SmartFormControl.aspx

2. If somehow you can find out original URL rewrite it back (wiht
HttpContext.RewritePath) before page is rendered to make HtmlForm output
"/jake.aspx" in action property.



George.



"Willy" wrote in message
news:EBE0BDB9-6867-4925-9365-50FBE8D60D42@microsoft.com...
> So ? I posted a sample, didn't I?
>
>> web.config:
>>
>> ...
>>
>>
>>
>>

>>

>>
>>
>> default.aspx:
>> Partial Class _Default
>> Inherits System.Web.UI.Page
>>
>> Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles Button1.Click
>> Server.Transfer(Me.Request.RawUrl)
>> End Sub
>>
>> Protected Sub Button2_Click(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles Button2.Click
>> Response.Redirect(Me.Request.RawUrl, False)
>> End Sub
>>
>> Protected Sub Button2_Load(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles Button2.Load
>> Button2.Text = "redirect " & Me.Request.RawUrl
>> End Sub
>> End Class
>>
>> Now I visit the page jake.aspx (which doesn't exist : it is a mapped
>> file).
>> My browser shows Jake.aspx
>> I click any of the buttons to "refresh" the current page (I change the
>> language of the current thread in the meantime).
>> My browser shows Default.aspx. But I want it to be jake.aspx
>>
>

Re: Forcing browser to reload the "same page" with "mapped URL"

am 04.04.2008 00:21:39 von Willy

Hello George,

All I needed to do was add code
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreRender
Me.Context.RewritePath(Me.Request.RawUrl)
End Sub
to my page to make it work. I didn't know about the *rewritePath* trick.
But it will sure go into my basket
I checked with SiteMapPath control and this one is also very happy.

Thanks a lot.
Van den Driessche Willy.

Re: Forcing browser to reload the "same page" with "mapped URL"

am 04.04.2008 14:57:14 von George Ter-Saakov

Cool, that was easier than I thought.
I thought that RawUrl will point to already rewritten Url.

George.

"Willy" wrote in message
news:1FA8F541-7DA0-4056-8DC7-C8D78B44869E@microsoft.com...
> Hello George,
>
> All I needed to do was add code
> Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.PreRender
> Me.Context.RewritePath(Me.Request.RawUrl)
> End Sub
> to my page to make it work. I didn't know about the *rewritePath* trick.
> But it will sure go into my basket
> I checked with SiteMapPath control and this one is also very happy.
>
> Thanks a lot.
> Van den Driessche Willy.