473,804 Members | 3,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PostBackUrl breaks url rewrite (Bug or unwanted feature).

Can not figure out why but if I have button with PostBackUrl specified it
breaks UrlRewrite. All buttons stop working. Form submits but corresponded
event procedure never called. And it only happens in rewritten urls.
Do not understand why it a happens, hope some one from Microsoft would took
a look at it. I spent about a day trying to pinpoint a problem. Finaly did.

Here are simple steps to reproduce the problem

1. Create project UrlRewrite.
2. In Global.asax write following code (to rewrite every .aspx request to
default.aspx, we do not want to rewrite request for WebResource.axd )
void Application_Beg inRequest(Objec t sender, EventArgs e)
{
System.Web.Http Context ctx = System.Web.Http Context.Current ;
string sPath = ctx.Request.Pat h.ToLower();
//check that we have request for .aspx page
int iIndex = sPath.IndexOf(" .aspx");
if (iIndex == -1)
return;

ctx.Items["OriginalPa th"] = sPath;
ctx.RewritePath ("~/default.aspx", null, null);
return;

}

3. Make default.aspx
<%@ Page Language="C#"%>
<script runat="server">
protected override void OnInit(EventArg s e)
{
base.OnInit(e);
//Fix HtmlForm action for proper rewrite.
string sPath = (string)Context .Items["OriginalPa th"];
Context.Rewrite Path(sPath, "", "");
}
protected void Button1_Click(o bject sender, EventArgs e)
{
Button1.Text = "Success";
}
</script>
<html>
<body>
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" OnClick="Button 1_Click"
Text="Try Me" />
<asp:Button ID="goBtn" runat="server" Text="Button"
PostBackUrl="/test.aspx"/>
</form>
</body>
</html>

by looking at this code you would say that when you hit Button1, Text =
"Try Me" will be replaced by "Success"

Start your project.
Url http://localhost/UrlRewrite/default.aspx works as expected
Url http://localhost/UrlRewrite/Test/default.aspx does not work, form
submits but button1_Click never called.

Remove PostBackUrl="/test.aspx" from goBtn and it starts working.

Thanks
George.


Jun 27 '08 #1
0 1361

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2738
by: VK | last post by:
a:active { color: #FF0000; text-decoration: underline} /* a:visited color rule has higher priority over a:hover if viewed from your local drive, so visited links will not "hover". To fix this bug (feature?) one should use additional !important instruction: */ a:hover { color: #FF0000 !important; text-decoration: underline} a:link { color: #0000FF; text-decoration: underline} a:visited { color: #800080; ; text-decoration: underline}
188
7264
by: christopher diggins | last post by:
I have posted a C# critique at http://www.heron-language.com/c-sharp-critique.html. To summarize I bring up the following issues : - unsafe code - attributes - garbage collection - non-deterministic destructors - Objects can't exist on the stack - Type / Reference Types
3
14889
by: bill | last post by:
I am using Visual Web Developer 2005. Can I use the button PostBackURL to open a second web form in a new window, instead of replacing the current page? Thanks Bill
1
8556
by: osh | last post by:
All, I am having trouble using the PostBackUrl feature in .NET 2.0. I have several User Controls that are on a MasterPage. The User Controls contain the form fields for a basic search on available homes and properties in a given area. I put these form fields into User Controls because they will be repeated in different ways throughout the site and it would be nice to only update the fields from one place to make a site wide change.
0
1011
by: Daves | last post by:
I have a paired TextBox and Button on my masterpage for login, this way user doesn't have to go to a special login page to do that - fewer clicks. The trick is done via PostBackUrl and in the target page the TextBox's class is built up again by this.PreviousPage.FindControl("textbox") ... Obviously, in the background the previous aspx page is re-run to initialise it's classes so that I can grab the entered value in the button's paired...
0
964
by: cmay | last post by:
I have a page with smartNav, that contains a linkbutton with a PostBackUrl. I have found that the page that is the target of the PostBackUrl will have it's postback property fired 2 times, and unfortunately, the 2nd time it is fired the "PreviousPage" is set to Nothing. Is this a known bug? Does anyone know a workaround for this?
1
1237
by: cider123 | last post by:
Is there a way to add a Datafield value to a PostBack URL in another column of the same row ? In my case I have this hidden value of SystemID: <Columns> <asp:BoundField DataField="SystemID" HeaderText="SystemID" InsertVisible="False" ReadOnly="True" SortExpression="SystemID" Visible="False" />
10
1318
by: not_a_commie | last post by:
I've seen studies before showing that it is better to rewrite code when more than 25% (or whatever) of the code needs to be changed. I can't seem to locate any references for that at the moment. Do any of you have references for that type of article? Thanks.
1
334
by: psycho | last post by:
i am creating a web page for importing user contacts from yahoo. i let the user enter his username and password on one page and then post it to another page by specifying the postbackurl for the button to next page where i access the username and password from previous page using the previous page property. Also i have specified the path of page in PreviousPageType directive in VirtualPath Property. sometimes this approach works fine...
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9572
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10303
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10070
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9132
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4282
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2978
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.