locked
Url Rewriting Action tag RRS feed

  • Question

  • User-1069184416 posted
    Hello experts, could you please read this article, and tell me what is wrong with normal URL Rewriting ? What is that problem in that article ?

    http://weblogs.asp.net/jezell/archive/2004/03/15/90045.aspx

    regards
    Tuesday, April 12, 2005 5:26 AM

All replies

  • User948010097 posted

    The problem lies in a combination of things.

    1. The action attribute of the HtmlForm control is determined by removing all the path context from the current url. So if you are on /products/test.aspx, the action Attribute will say "test.aspx".

    2. The HtmlForm control has no idea you rewrote the url. It always uses the physical file path.

    So if you have /products/goodstuff/foobar.aspx as the friendly url the client sees, but you rewrote it to /products/realpage.aspx, the action attribute will only say "realpage.aspx", so when yo post-back, your client is posting to /products/goodstuff/realpage.aspx which doesn't exist, and they get a 404 error.

    Scott Mitchell mentions in this article that you can make your own form class that inherits HtmlForm, then completely remove the action attribute in the RenderAttributes method. It's not a perfect solution though, because there are internal methods and properties that you cannot access in your subclass. So you will be unable to completely reproduce the functionality that that method normally has.

    - Todd Moon

    Wednesday, April 13, 2005 12:54 AM
  • User-1069184416 posted
    So is URL rewriting a -ve thing to do ?

    regards
    Wednesday, April 13, 2005 7:59 AM
  • User948010097 posted
    I don't understand the question. A "-ve thing" ?
    Wednesday, April 13, 2005 9:15 AM
  • User-1069184416 posted
    What i mean, will that thing be an obstacle for the URL to work well ?

    regards
    Wednesday, April 13, 2005 12:40 PM
  • User-1069184416 posted
    Is it explained well in that article ? I read it from a long time. I guess I should read it again.

    Regards
    Wednesday, April 13, 2005 3:28 PM