I want to control the action of the form being rewritten in postBack.

Asked 2 years ago, Updated 2 years ago, 134 views

I'm sorry.
Let's start with the symptom.

at
/dirBefore/xxx.aspx
    Server.Transfer("/dirAfter/yyy.aspx") is running and displayed
at /dirAfter/yyy.aspx
    <asp: Postbacking from TextBox AutoPostBack="true"/>
    The action of the form is rewritten to "/dirBefore/yyy.aspx"

By the way

<asp:button UseSubmitBehavior="false"/>

If you submit it first, you will not experience any more symptoms.

So the question is
This rewrite is done on which module
How can I control it?
That's it.

By the way, here
URL Rewrite for ASP.NET Web Form
https://technet.microsoft.com/ja-jp/library/ee890797.aspx
I referred to and did the following, but it is not understood and will not be resolved.

Try configuring Form.Action
The absolute path below was successful for now, but

Private Sub Page_Load(...) Handles MyBase.Load
  Page.Form.Action = Page.Request.CurrentExecutionFilePath
End Sub

For some reason, I had to make the session cookie-less.
Therefore, I changed it to a relative path as follows (though it is careless).
This may result in rewriting at the time of submission.

Private Sub Page_Load(...) Handles MyBase.Load
  Page.Form.Action="..." & Page.Request.CurrentExecutionFilePath
End Sub

It may be rewritten if the depth of the path before and after Transfer is different.
Unconfirmed.

In the first place, the action of the form remains the browser source.
If you don't rewrite it without permission, you don't have to go through all this trouble like this.
They want to know how to disable the rewrite operation or otherwise manipulate the rewrite path.

Thank you for your cooperation.

asp.net

2022-09-30 21:22

1 Answers

The action sent by asynchronous postback is likely to be the same ./yyy.aspx as if for some reason you were not using Server.Transfer.

As a countermeasure, you can specify the action attribute by setting Page.Form.Action in the appropriate event of code behind.If you want to make it common, would it be Page_PreRenderComplete?


2022-09-30 21:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.