locked
Problem with URL redirection in auto postback RRS feed

  • Question

  • User634162577 posted

    Hi,

    I am using URL Redirection in my project (ASP.net 2.0 with VB)

    I just done all the rewriting process in global.asax

    If the file name is http://mydomain/category_cat_id.html
    then it will rediret to http://mydomain/show_category.aspx?cat_id=cat_id (here cat_id derived from html file)

    In my show_category.aspx file i have one Drop down which is Auto PostBack is true.

    When the page is postback what i get the url is http://mydomain/category_cat_id.html?cat_id=1

    But i dont want the querystring in html file

    I just wirte the following code in page_load event

    Dim url As String = Request.RawUrl

    Dim index As Integer = url.LastIndexOf(".html")

    ViewState("RequestUrl") = Request.RawUrl.Substring(0, index + 1) & "html"

    Context.RewritePath(ViewState("RequestUrl"))


    Please help how to redirect to the same html url in auto postback event?

     

    With Regards

    Antony

    Tuesday, May 29, 2007 10:00 AM

Answers

  • User-225114762 posted

    Your problem here is that UrlRewriting the way you do it only affects incoming URL's - not outgoing, i.e. the ones in your rendered HTML unless you explicitly ensure that you use your 'external' form when rendering your HTML. For this to work you need to ensure that the HTML that goes out uses the URL's you want. There's no built-in direct support for this in ASP.NET. You can do it on a control-by-control basis where you need it, or you can implement a HTML filter in the outgoing stream, parse all outgoing HTML and do your own reverse-rewrite before the content actually goes to the client.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 30, 2007 7:43 AM

All replies

  • User1863176706 posted

    Hi there.

    Why don't you just simply use the Server.Transfer("mypage.aspx?myparam=myvalue") method?
    This let's another page take control of the current request without even touching the original request url.

    Regards,
    Jorge

    Tuesday, May 29, 2007 10:20 AM
  • User-225114762 posted

    Your problem here is that UrlRewriting the way you do it only affects incoming URL's - not outgoing, i.e. the ones in your rendered HTML unless you explicitly ensure that you use your 'external' form when rendering your HTML. For this to work you need to ensure that the HTML that goes out uses the URL's you want. There's no built-in direct support for this in ASP.NET. You can do it on a control-by-control basis where you need it, or you can implement a HTML filter in the outgoing stream, parse all outgoing HTML and do your own reverse-rewrite before the content actually goes to the client.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 30, 2007 7:43 AM
  • User634162577 posted

    Hi Svante

    Thx for your reply. I got your point.

     

    Wednesday, May 30, 2007 9:45 AM