tags:

views:

449

answers:

2

Hello

i have a problem when i RewritePath in HttpContext,

context.RewritePath(Utility.WebRoot + "List/Add.aspx", false);

It work fine to rewrite the url: http://localhost/List/Add

But when i hit the button it redirect me to http://localhost/List/Add.aspx

Is there a good way to "stop" the redirection to the .aspx page and just leave it on http://localhost/List/Add ?

Thanks for help

+1  A: 

There is an issue with the From tag. You have to use a Control Adapter like this one:

http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx Go to the "Handling ASP.NET PostBacks with URL Rewriting" section.

Arthur
Solved it with this: http://ruslany.net/2008/10/aspnet-postbacks-and-url-rewriting/
Frozzare
A: 

This will help: http://www.codeproject.com/KB/aspnet/SmartFormControl.aspx

Basically the idea is to create a new Form control (I called my "ActionlessFormControl") that derives from the .Net Form control. The gist of it is that you override the rendering of the attributes and set your own value for the "action" attribute. What I do in mine is I remove the "action" attribute altogether which will post back to the same URL. Meaning, your page will post back to "/List/Add".

The benefit from using the inherited control is that you don't have to "register" each page. This will allow you to have dynamic content/URLS post back correctly.

Jonathan