473,396 Members | 1,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ControlAdapter sample from Scott Gu no more work ?

WT
Hello,

Using url rewritting and ajax.net, I tried to circumvent some potential
problems with postback url using a code from a sample given by Scott.
The idea is to use a control Adapter on htmlform to catch the attribute
'action' wich contains the url where the post will occur and replace it with
a safe url.
Unfortunately, it doesn't works, does something has changed with framework
3.5 used by vs2008 ?
From the trace I put inside I can see that the adapter is working but I
never get an attribute named action ????

Here is the code:

public class FormRewriterControlAdapter : ControlAdapter
{
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
base.Render(new RewriteFormHtmlTextWriter(writer));
}
}

public class RewriteFormHtmlTextWriter : HtmlTextWriter
{
public RewriteFormHtmlTextWriter(HtmlTextWriter writer)
: base(writer)
{
InnerWriter = writer.InnerWriter;
}

public RewriteFormHtmlTextWriter(TextWriter writer)
: base(writer)
{
InnerWriter = writer;
}

/// <summary>
/// If the attribute we are writing is the "action" attribute, and
we are not on a sub-control,
/// then replace the value to write with the raw URL of the
request - which ensures that we'll
/// preserve the PathInfo value on postback scenarios
/// </summary>
public override void AddAttribute(string name, string value, bool
fEncode)
{
HttpContext Context =
HttpContext.Current;
if ( name.Equals("action") )
{
if (Context != null && Context.Items["ActionAlreadyWritten"]
== null)
{
value =
Context.Request.RawUrl;
// Indicate that we've already rewritten the <form>'s
action attribute to prevent
// us from rewriting a sub-control under the <form>
control
Context.Items["ActionAlreadyWritten"] = true;
}
}
base.AddAttribute(name, value, fEncode);
}

}

I have also a special declaration in my web site Form_Browsers folder

<browsers>
<browser refID="Default">
<controlAdapters>
<adapter controlType="System.Web.UI.HtmlControls.HtmlForm"
adapterType="AddonNice.Core.UI.Adapters.FormRewrit erControlAdapter" />
</controlAdapters>
</browser>
</browsers>

Thanks to any help on this, it is so simple that the error must be
evident.....but.

CS

Sep 24 '08 #1
6 1606
HtmlForm as been recoded and no longer uses the attribute collection to
determine what to render for the action. Action has been exposed as a
property you can just set in your code or your adapter.

-- bruce (sqlwork.com)

WT wrote:
Hello,

Using url rewritting and ajax.net, I tried to circumvent some potential
problems with postback url using a code from a sample given by Scott.
The idea is to use a control Adapter on htmlform to catch the attribute
'action' wich contains the url where the post will occur and replace it
with a safe url.
Unfortunately, it doesn't works, does something has changed with
framework 3.5 used by vs2008 ?
From the trace I put inside I can see that the adapter is working but I
never get an attribute named action ????

Here is the code:

public class FormRewriterControlAdapter : ControlAdapter
{
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
base.Render(new RewriteFormHtmlTextWriter(writer));
}
}

public class RewriteFormHtmlTextWriter : HtmlTextWriter
{
public RewriteFormHtmlTextWriter(HtmlTextWriter writer)
: base(writer)
{
InnerWriter = writer.InnerWriter;
}

public RewriteFormHtmlTextWriter(TextWriter writer)
: base(writer)
{
InnerWriter = writer;
}

/// <summary>
/// If the attribute we are writing is the "action" attribute,
and we are not on a sub-control,
/// then replace the value to write with the raw URL of the
request - which ensures that we'll
/// preserve the PathInfo value on postback scenarios
/// </summary>
public override void AddAttribute(string name, string value, bool
fEncode)
{
HttpContext Context =
HttpContext.Current;
if ( name.Equals("action") )
{
if (Context != null &&
Context.Items["ActionAlreadyWritten"] == null)
{
value =
Context.Request.RawUrl;
// Indicate that we've already rewritten the <form>'s
action attribute to prevent
// us from rewriting a sub-control under the <form>
control
Context.Items["ActionAlreadyWritten"] = true;
}
}
base.AddAttribute(name, value, fEncode);
}

}

I have also a special declaration in my web site Form_Browsers folder

<browsers>
<browser refID="Default">
<controlAdapters>
<adapter controlType="System.Web.UI.HtmlControls.HtmlForm"
adapterType="AddonNice.Core.UI.Adapters.FormRewrit erControlAdapter" />
</controlAdapters>
</browser>
</browsers>

Thanks to any help on this, it is so simple that the error must be
evident.....but.

CS
Sep 25 '08 #2
Hi,

I've tested Scott's project:
http://www.scottgu.com/blogposts/url...ttpModule1.zip

It works fine. Could you try it again to see if it works? Firstly please
view the page Default.aspx. Then click a link on the page to view
Products.aspx. View source of Products.aspx and you will see the action
attribute in the form tag:
<form name="form1" method="post" action="/SOS/Products.aspx" id="form1">

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: "WT" <WT@newsgroups.nospam>
| Subject: ControlAdapter sample from Scott Gu no more work ?
| Date: Wed, 24 Sep 2008 18:42:32 +0200
| Lines: 85
| Message-ID: <5A**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| format=flowed;
| charset="iso-8859-1";
| reply-type=original
| Content-Transfer-Encoding: 7bit
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Windows Mail 6.0.6001.18000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049
| X-MS-CommunityGroup-MessageCategory:
{E4FCE0A9-75B4-4168-BFF9-16C22D8747EC}
| X-MS-CommunityGroup-PostID: {5AE30215-24F1-48F9-B9EC-16707DAD2F45}
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:76663
| NNTP-Posting-Host: TK2MSFTNGHUB02.phx.gbl 127.0.0.1
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hello,
|
| Using url rewritting and ajax.net, I tried to circumvent some potential
| problems with postback url using a code from a sample given by Scott.
| The idea is to use a control Adapter on htmlform to catch the attribute
| 'action' wich contains the url where the post will occur and replace it
with
| a safe url.
| Unfortunately, it doesn't works, does something has changed with
framework
| 3.5 used by vs2008 ?
| From the trace I put inside I can see that the adapter is working but I
| never get an attribute named action ????
|
| Here is the code:
|
| public class FormRewriterControlAdapter : ControlAdapter
| {
| protected override void Render(System.Web.UI.HtmlTextWriter
writer)
| {
| base.Render(new RewriteFormHtmlTextWriter(writer));
| }
| }
|
| public class RewriteFormHtmlTextWriter : HtmlTextWriter
| {
| public RewriteFormHtmlTextWriter(HtmlTextWriter writer)
| : base(writer)
| {
| InnerWriter = writer.InnerWriter;
| }
|
| public RewriteFormHtmlTextWriter(TextWriter writer)
| : base(writer)
| {
| InnerWriter = writer;
| }
|
| /// <summary>
| /// If the attribute we are writing is the "action" attribute,
and
| we are not on a sub-control,
| /// then replace the value to write with the raw URL of the
| request - which ensures that we'll
| /// preserve the PathInfo value on postback scenarios
| /// </summary>
| public override void AddAttribute(string name, string value, bool
| fEncode)
| {
| HttpContext Context =
| HttpContext.Current;
| if ( name.Equals("action") )
| {
| if (Context != null &&
Context.Items["ActionAlreadyWritten"]
| == null)
| {
| value =
| Context.Request.RawUrl;
| // Indicate that we've already rewritten the <form>'s
| action attribute to prevent
| // us from rewriting a sub-control under the <form>
| control
| Context.Items["ActionAlreadyWritten"] = true;
| }
| }
| base.AddAttribute(name, value, fEncode);
| }
|
| }
|
| I have also a special declaration in my web site Form_Browsers folder
|
| <browsers>
| <browser refID="Default">
| <controlAdapters>
| <adapter controlType="System.Web.UI.HtmlControls.HtmlForm"
| adapterType="AddonNice.Core.UI.Adapters.FormRewrit erControlAdapter" />
| </controlAdapters>
| </browser>
| </browsers>
|
|
|
| Thanks to any help on this, it is so simple that the error must be
| evident.....but.
|
| CS
|
|

Sep 25 '08 #3
WT
Thanks,
Have you seen message from Bruce ?

Regards
CS
"Allen Chen [MSFT]" <v-******@online.microsoft.coma écrit dans le message
de news:Ft**************@TK2MSFTNGHUB02.phx.gbl...
Hi,

I've tested Scott's project:
http://www.scottgu.com/blogposts/url...ttpModule1.zip

It works fine. Could you try it again to see if it works? Firstly please
view the page Default.aspx. Then click a link on the page to view
Products.aspx. View source of Products.aspx and you will see the action
attribute in the form tag:
<form name="form1" method="post" action="/SOS/Products.aspx" id="form1">

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
| From: "WT" <WT@newsgroups.nospam>
| Subject: ControlAdapter sample from Scott Gu no more work ?
| Date: Wed, 24 Sep 2008 18:42:32 +0200
| Lines: 85
| Message-ID: <5A**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| format=flowed;
| charset="iso-8859-1";
| reply-type=original
| Content-Transfer-Encoding: 7bit
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Windows Mail 6.0.6001.18000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049
| X-MS-CommunityGroup-MessageCategory:
{E4FCE0A9-75B4-4168-BFF9-16C22D8747EC}
| X-MS-CommunityGroup-PostID: {5AE30215-24F1-48F9-B9EC-16707DAD2F45}
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:76663
| NNTP-Posting-Host: TK2MSFTNGHUB02.phx.gbl 127.0.0.1
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hello,
|
| Using url rewritting and ajax.net, I tried to circumvent some potential
| problems with postback url using a code from a sample given by Scott.
| The idea is to use a control Adapter on htmlform to catch the attribute
| 'action' wich contains the url where the post will occur and replace it
with
| a safe url.
| Unfortunately, it doesn't works, does something has changed with
framework
| 3.5 used by vs2008 ?
| From the trace I put inside I can see that the adapter is working but I
| never get an attribute named action ????
|
| Here is the code:
|
| public class FormRewriterControlAdapter : ControlAdapter
| {
| protected override void Render(System.Web.UI.HtmlTextWriter
writer)
| {
| base.Render(new RewriteFormHtmlTextWriter(writer));
| }
| }
|
| public class RewriteFormHtmlTextWriter : HtmlTextWriter
| {
| public RewriteFormHtmlTextWriter(HtmlTextWriter writer)
| : base(writer)
| {
| InnerWriter = writer.InnerWriter;
| }
|
| public RewriteFormHtmlTextWriter(TextWriter writer)
| : base(writer)
| {
| InnerWriter = writer;
| }
|
| /// <summary>
| /// If the attribute we are writing is the "action" attribute,
and
| we are not on a sub-control,
| /// then replace the value to write with the raw URL of the
| request - which ensures that we'll
| /// preserve the PathInfo value on postback scenarios
| /// </summary>
| public override void AddAttribute(string name, string value,
bool
| fEncode)
| {
| HttpContext Context =
| HttpContext.Current;
| if ( name.Equals("action") )
| {
| if (Context != null &&
Context.Items["ActionAlreadyWritten"]
| == null)
| {
| value =
| Context.Request.RawUrl;
| // Indicate that we've already rewritten the
<form>'s
| action attribute to prevent
| // us from rewriting a sub-control under the <form>
| control
| Context.Items["ActionAlreadyWritten"] = true;
| }
| }
| base.AddAttribute(name, value, fEncode);
| }
|
| }
|
| I have also a special declaration in my web site Form_Browsers folder
|
| <browsers>
| <browser refID="Default">
| <controlAdapters>
| <adapter controlType="System.Web.UI.HtmlControls.HtmlForm"
| adapterType="AddonNice.Core.UI.Adapters.FormRewrit erControlAdapter" />
| </controlAdapters>
| </browser>
| </browsers>
|
|
|
| Thanks to any help on this, it is so simple that the error must be
| evident.....but.
|
| CS
|
|
Sep 25 '08 #4
Hi,

I believe the change what Bruce mentioned is in the .NET 3.5 SP1. Are you
using .NET 3.5 SP1?

Actually the Action property is a shortcut to set/get the action attribute.
We can confirm it with the source code below:

public string Action
{
get
{
string str = base.Attributes["action"];
if (str == null)
{
return string.Empty;
}
return str;
}
set
{
base.Attributes["action"] =
HtmlControl.MapStringAttributeToString(value);
}
}
I tried Scott's project in Visual Studio 2008 SP1, it still works. Could
you try it again and paste the form tag here? The behavior on my side is:

1. Default.aspx:
<form name="form1" method="post"
action="/UrlRewrite_HttpModule1/Default.aspx" id="form1">

2. I clicked "Books" link to view Products.aspx:
<form name="form1" method="post"
action="/UrlRewrite_HttpModule1/Products/Books.aspx" id="form1">

Regards,
Allen Chen
Microsoft Online Community Support

--------------------
| From: "WT" <WT@newsgroups.nospam>
| References: <5A**********************************@microsoft.co m>
<Ft**************@TK2MSFTNGHUB02.phx.gbl>
| In-Reply-To: <Ft**************@TK2MSFTNGHUB02.phx.gbl>
| Subject: Re: ControlAdapter sample from Scott Gu no more work ?
| Date: Thu, 25 Sep 2008 16:46:52 +0200
| Lines: 168
| Message-ID: <8B**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| format=flowed;
| charset="iso-8859-1";
| reply-type=original
| Content-Transfer-Encoding: 8bit
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Windows Mail 6.0.6001.18000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049
| X-MS-CommunityGroup-PostID: {8B1FCBF4-9ECC-4A44-AC55-8EC6E11003AA}
| X-MS-CommunityGroup-ThreadID: 5AE30215-24F1-48F9-B9EC-16707DAD2F45
| X-MS-CommunityGroup-ParentID: FED06D18-3C27-46FE-A8F1-D1E348B75CFC
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:76742
| NNTP-Posting-Host: TK2MSFTNGHUB02.phx.gbl 127.0.0.1
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Thanks,
| Have you seen message from Bruce ?
|
| Regards
| CS
| "Allen Chen [MSFT]" <v-******@online.microsoft.coma écrit dans le
message
| de news:Ft**************@TK2MSFTNGHUB02.phx.gbl...
| Hi,
| >
| I've tested Scott's project:
| http://www.scottgu.com/blogposts/url...ttpModule1.zip
| >
| It works fine. Could you try it again to see if it works? Firstly please
| view the page Default.aspx. Then click a link on the page to view
| Products.aspx. View source of Products.aspx and you will see the action
| attribute in the form tag:
| <form name="form1" method="post" action="/SOS/Products.aspx" id="form1">
| >
| Regards,
| Allen Chen
| Microsoft Online Support
| >
| Delighting our customers is our #1 priority. We welcome your comments
and
| suggestions about how we can improve the support we provide to you.
Please
| feel free to let my manager know what you think of the level of service
| provided. You can send feedback directly to my manager at:
| ms****@microsoft.com.
| >
| ==================================================
| Get notification to my posts through email? Please refer to
| >
http://msdn.microsoft.com/en-us/subs...#notifications.
| >
| Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
| where an initial response from the community or a Microsoft Support
| Engineer within 1 business day is acceptable. Please note that each
follow
| up response may take approximately 2 business days as the support
| professional working with you may need further investigation to reach
the
| most efficient resolution. The offering is not appropriate for
situations
| that require urgent, real-time or phone-based interactions or complex
| project analysis and dump analysis issues. Issues of this nature are
best
| handled working with a dedicated Microsoft Support Engineer by
contacting
| Microsoft Customer Support Services (CSS) at
| >
http://support.microsoft.com/select/...tance&ln=en-us.
| ==================================================
| This posting is provided "AS IS" with no warranties, and confers no
| rights.
| >
| --------------------
| | From: "WT" <WT@newsgroups.nospam>
| | Subject: ControlAdapter sample from Scott Gu no more work ?
| | Date: Wed, 24 Sep 2008 18:42:32 +0200
| | Lines: 85
| | Message-ID: <5A**********************************@microsoft.co m>
| | MIME-Version: 1.0
| | Content-Type: text/plain;
| | format=flowed;
| | charset="iso-8859-1";
| | reply-type=original
| | Content-Transfer-Encoding: 7bit
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Windows Mail 6.0.6001.18000
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049
| | X-MS-CommunityGroup-MessageCategory:
| {E4FCE0A9-75B4-4168-BFF9-16C22D8747EC}
| | X-MS-CommunityGroup-PostID: {5AE30215-24F1-48F9-B9EC-16707DAD2F45}
| | Newsgroups: microsoft.public.dotnet.framework.aspnet
| | Path: TK2MSFTNGHUB02.phx.gbl
| | Xref: TK2MSFTNGHUB02.phx.gbl
| microsoft.public.dotnet.framework.aspnet:76663
| | NNTP-Posting-Host: TK2MSFTNGHUB02.phx.gbl 127.0.0.1
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| |
| | Hello,
| |
| | Using url rewritting and ajax.net, I tried to circumvent some
potential
| | problems with postback url using a code from a sample given by Scott.
| | The idea is to use a control Adapter on htmlform to catch the
attribute
| | 'action' wich contains the url where the post will occur and replace
it
| with
| | a safe url.
| | Unfortunately, it doesn't works, does something has changed with
| framework
| | 3.5 used by vs2008 ?
| | From the trace I put inside I can see that the adapter is working but
I
| | never get an attribute named action ????
| |
| | Here is the code:
| |
| | public class FormRewriterControlAdapter : ControlAdapter
| | {
| | protected override void Render(System.Web.UI.HtmlTextWriter
| writer)
| | {
| | base.Render(new RewriteFormHtmlTextWriter(writer));
| | }
| | }
| |
| | public class RewriteFormHtmlTextWriter : HtmlTextWriter
| | {
| | public RewriteFormHtmlTextWriter(HtmlTextWriter writer)
| | : base(writer)
| | {
| | InnerWriter = writer.InnerWriter;
| | }
| |
| | public RewriteFormHtmlTextWriter(TextWriter writer)
| | : base(writer)
| | {
| | InnerWriter = writer;
| | }
| |
| | /// <summary>
| | /// If the attribute we are writing is the "action" attribute,
| and
| | we are not on a sub-control,
| | /// then replace the value to write with the raw URL of the
| | request - which ensures that we'll
| | /// preserve the PathInfo value on postback scenarios
| | /// </summary>
| | public override void AddAttribute(string name, string value,
| bool
| | fEncode)
| | {
| | HttpContext Context =
| | HttpContext.Current;
| | if ( name.Equals("action") )
| | {
| | if (Context != null &&
| Context.Items["ActionAlreadyWritten"]
| | == null)
| | {
| | value =
| | Context.Request.RawUrl;
| | // Indicate that we've already rewritten the
| <form>'s
| | action attribute to prevent
| | // us from rewriting a sub-control under the
<form>
| | control
| | Context.Items["ActionAlreadyWritten"] = true;
| | }
| | }
| | base.AddAttribute(name, value, fEncode);
| | }
| |
| | }
| |
| | I have also a special declaration in my web site Form_Browsers folder
| |
| | <browsers>
| | <browser refID="Default">
| | <controlAdapters>
| | <adapter controlType="System.Web.UI.HtmlControls.HtmlForm"
| | adapterType="AddonNice.Core.UI.Adapters.FormRewrit erControlAdapter" />
| | </controlAdapters>
| | </browser>
| | </browsers>
| |
| |
| |
| | Thanks to any help on this, it is so simple that the error must be
| | evident.....but.
| |
| | CS
| |
| |
| >
|
|

Sep 26 '08 #5
WT
Yes I am using the 3.5 SP1.
I try your code and give a feed-back, thanks.
CS

"Allen Chen [MSFT]" <v-******@online.microsoft.coma écrit dans le message
de news:Sp**************@TK2MSFTNGHUB02.phx.gbl...
Hi,

I believe the change what Bruce mentioned is in the .NET 3.5 SP1. Are you
using .NET 3.5 SP1?

Actually the Action property is a shortcut to set/get the action
attribute.
We can confirm it with the source code below:

public string Action
{
get
{
string str = base.Attributes["action"];
if (str == null)
{
return string.Empty;
}
return str;
}
set
{
base.Attributes["action"] =
HtmlControl.MapStringAttributeToString(value);
}
}
I tried Scott's project in Visual Studio 2008 SP1, it still works. Could
you try it again and paste the form tag here? The behavior on my side is:

1. Default.aspx:
<form name="form1" method="post"
action="/UrlRewrite_HttpModule1/Default.aspx" id="form1">

2. I clicked "Books" link to view Products.aspx:
<form name="form1" method="post"
action="/UrlRewrite_HttpModule1/Products/Books.aspx" id="form1">

Regards,
Allen Chen
Microsoft Online Community Support

--------------------
| From: "WT" <WT@newsgroups.nospam>
| References: <5A**********************************@microsoft.co m>
<Ft**************@TK2MSFTNGHUB02.phx.gbl>
| In-Reply-To: <Ft**************@TK2MSFTNGHUB02.phx.gbl>
| Subject: Re: ControlAdapter sample from Scott Gu no more work ?
| Date: Thu, 25 Sep 2008 16:46:52 +0200
| Lines: 168
| Message-ID: <8B**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| format=flowed;
| charset="iso-8859-1";
| reply-type=original
| Content-Transfer-Encoding: 8bit
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Windows Mail 6.0.6001.18000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049
| X-MS-CommunityGroup-PostID: {8B1FCBF4-9ECC-4A44-AC55-8EC6E11003AA}
| X-MS-CommunityGroup-ThreadID: 5AE30215-24F1-48F9-B9EC-16707DAD2F45
| X-MS-CommunityGroup-ParentID: FED06D18-3C27-46FE-A8F1-D1E348B75CFC
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:76742
| NNTP-Posting-Host: TK2MSFTNGHUB02.phx.gbl 127.0.0.1
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Thanks,
| Have you seen message from Bruce ?
|
| Regards
| CS
| "Allen Chen [MSFT]" <v-******@online.microsoft.coma écrit dans le
message
| de news:Ft**************@TK2MSFTNGHUB02.phx.gbl...
| Hi,
| >
| I've tested Scott's project:
| http://www.scottgu.com/blogposts/url...ttpModule1.zip
| >
| It works fine. Could you try it again to see if it works? Firstly
please
| view the page Default.aspx. Then click a link on the page to view
| Products.aspx. View source of Products.aspx and you will see the
action
| attribute in the form tag:
| <form name="form1" method="post" action="/SOS/Products.aspx"
id="form1">
| >
| Regards,
| Allen Chen
| Microsoft Online Support
| >
| Delighting our customers is our #1 priority. We welcome your comments
and
| suggestions about how we can improve the support we provide to you.
Please
| feel free to let my manager know what you think of the level of
service
| provided. You can send feedback directly to my manager at:
| ms****@microsoft.com.
| >
| ==================================================
| Get notification to my posts through email? Please refer to
| >
http://msdn.microsoft.com/en-us/subs...#notifications.
| >
| Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
| where an initial response from the community or a Microsoft Support
| Engineer within 1 business day is acceptable. Please note that each
follow
| up response may take approximately 2 business days as the support
| professional working with you may need further investigation to reach
the
| most efficient resolution. The offering is not appropriate for
situations
| that require urgent, real-time or phone-based interactions or complex
| project analysis and dump analysis issues. Issues of this nature are
best
| handled working with a dedicated Microsoft Support Engineer by
contacting
| Microsoft Customer Support Services (CSS) at
| >
http://support.microsoft.com/select/...tance&ln=en-us.
| ==================================================
| This posting is provided "AS IS" with no warranties, and confers no
| rights.
| >
| --------------------
| | From: "WT" <WT@newsgroups.nospam>
| | Subject: ControlAdapter sample from Scott Gu no more work ?
| | Date: Wed, 24 Sep 2008 18:42:32 +0200
| | Lines: 85
| | Message-ID: <5A**********************************@microsoft.co m>
| | MIME-Version: 1.0
| | Content-Type: text/plain;
| | format=flowed;
| | charset="iso-8859-1";
| | reply-type=original
| | Content-Transfer-Encoding: 7bit
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Windows Mail 6.0.6001.18000
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049
| | X-MS-CommunityGroup-MessageCategory:
| {E4FCE0A9-75B4-4168-BFF9-16C22D8747EC}
| | X-MS-CommunityGroup-PostID: {5AE30215-24F1-48F9-B9EC-16707DAD2F45}
| | Newsgroups: microsoft.public.dotnet.framework.aspnet
| | Path: TK2MSFTNGHUB02.phx.gbl
| | Xref: TK2MSFTNGHUB02.phx.gbl
| microsoft.public.dotnet.framework.aspnet:76663
| | NNTP-Posting-Host: TK2MSFTNGHUB02.phx.gbl 127.0.0.1
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| |
| | Hello,
| |
| | Using url rewritting and ajax.net, I tried to circumvent some
potential
| | problems with postback url using a code from a sample given by
Scott.
| | The idea is to use a control Adapter on htmlform to catch the
attribute
| | 'action' wich contains the url where the post will occur and replace
it
| with
| | a safe url.
| | Unfortunately, it doesn't works, does something has changed with
| framework
| | 3.5 used by vs2008 ?
| | From the trace I put inside I can see that the adapter is working
but
I
| | never get an attribute named action ????
| |
| | Here is the code:
| |
| | public class FormRewriterControlAdapter : ControlAdapter
| | {
| | protected override void Render(System.Web.UI.HtmlTextWriter
| writer)
| | {
| | base.Render(new RewriteFormHtmlTextWriter(writer));
| | }
| | }
| |
| | public class RewriteFormHtmlTextWriter : HtmlTextWriter
| | {
| | public RewriteFormHtmlTextWriter(HtmlTextWriter writer)
| | : base(writer)
| | {
| | InnerWriter = writer.InnerWriter;
| | }
| |
| | public RewriteFormHtmlTextWriter(TextWriter writer)
| | : base(writer)
| | {
| | InnerWriter = writer;
| | }
| |
| | /// <summary>
| | /// If the attribute we are writing is the "action"
attribute,
| and
| | we are not on a sub-control,
| | /// then replace the value to write with the raw URL of the
| | request - which ensures that we'll
| | /// preserve the PathInfo value on postback scenarios
| | /// </summary>
| | public override void AddAttribute(string name, string value,
| bool
| | fEncode)
| | {
| | HttpContext Context =
| | HttpContext.Current;
| | if ( name.Equals("action") )
| | {
| | if (Context != null &&
| Context.Items["ActionAlreadyWritten"]
| | == null)
| | {
| | value =
| | Context.Request.RawUrl;
| | // Indicate that we've already rewritten the
| <form>'s
| | action attribute to prevent
| | // us from rewriting a sub-control under the
<form>
| | control
| | Context.Items["ActionAlreadyWritten"] =
true;
| | }
| | }
| | base.AddAttribute(name, value, fEncode);
| | }
| |
| | }
| |
| | I have also a special declaration in my web site Form_Browsers
folder
| |
| | <browsers>
| | <browser refID="Default">
| | <controlAdapters>
| | <adapter controlType="System.Web.UI.HtmlControls.HtmlForm"
| | adapterType="AddonNice.Core.UI.Adapters.FormRewrit erControlAdapter"
/>
| | </controlAdapters>
| | </browser>
| | </browsers>
| |
| |
| |
| | Thanks to any help on this, it is so simple that the error must be
| | evident.....but.
| |
| | CS
| |
| |
| >
|
|
Sep 26 '08 #6
Hi,

What's the test result? Can it work?

Regards,
Allen Chen
Microsoft Online Support
--------------------
| From: "WT" <WT@newsgroups.nospam>
| References: <5A**********************************@microsoft.co m>
<Ft**************@TK2MSFTNGHUB02.phx.gbl>
<8B**********************************@microsoft.co m>
<Sp**************@TK2MSFTNGHUB02.phx.gbl>
| In-Reply-To: <Sp**************@TK2MSFTNGHUB02.phx.gbl>
| Subject: Re: ControlAdapter sample from Scott Gu no more work ?
| Date: Fri, 26 Sep 2008 11:55:38 +0200
| Lines: 275
| Message-ID: <CB**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| format=flowed;
| charset="iso-8859-1";
| reply-type=original
| Content-Transfer-Encoding: 8bit
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Windows Mail 6.0.6001.18000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049
| X-MS-CommunityGroup-PostID: {CBD0FA70-47EA-4A4D-9B82-3307BB0F35BE}
| X-MS-CommunityGroup-ThreadID: 5AE30215-24F1-48F9-B9EC-16707DAD2F45
| X-MS-CommunityGroup-ParentID: B24F20C7-BA52-4E25-90DF-BC3FD5520FF2
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:76777
| NNTP-Posting-Host: TK2MSFTNGHUB02.phx.gbl 127.0.0.1
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Yes I am using the 3.5 SP1.
| I try your code and give a feed-back, thanks.
| CS
|
| "Allen Chen [MSFT]" <v-******@online.microsoft.coma écrit dans le
message
| de news:Sp**************@TK2MSFTNGHUB02.phx.gbl...
| Hi,
| >
| I believe the change what Bruce mentioned is in the .NET 3.5 SP1. Are
you
| using .NET 3.5 SP1?
| >
| Actually the Action property is a shortcut to set/get the action
| attribute.
| We can confirm it with the source code below:
| >
| public string Action
| {
| get
| {
| string str = base.Attributes["action"];
| if (str == null)
| {
| return string.Empty;
| }
| return str;
| }
| set
| {
| base.Attributes["action"] =
| HtmlControl.MapStringAttributeToString(value);
| }
| }
| >
| >
| I tried Scott's project in Visual Studio 2008 SP1, it still works. Could
| you try it again and paste the form tag here? The behavior on my side
is:
| >
| 1. Default.aspx:
| <form name="form1" method="post"
| action="/UrlRewrite_HttpModule1/Default.aspx" id="form1">
| >
| 2. I clicked "Books" link to view Products.aspx:
| <form name="form1" method="post"
| action="/UrlRewrite_HttpModule1/Products/Books.aspx" id="form1">
| >
| Regards,
| Allen Chen
| Microsoft Online Community Support
| >
| --------------------
| | From: "WT" <WT@newsgroups.nospam>
| | References: <5A**********************************@microsoft.co m>
| <Ft**************@TK2MSFTNGHUB02.phx.gbl>
| | In-Reply-To: <Ft**************@TK2MSFTNGHUB02.phx.gbl>
| | Subject: Re: ControlAdapter sample from Scott Gu no more work ?
| | Date: Thu, 25 Sep 2008 16:46:52 +0200
| | Lines: 168
| | Message-ID: <8B**********************************@microsoft.co m>
| | MIME-Version: 1.0
| | Content-Type: text/plain;
| | format=flowed;
| | charset="iso-8859-1";
| | reply-type=original
| | Content-Transfer-Encoding: 8bit
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Windows Mail 6.0.6001.18000
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049
| | X-MS-CommunityGroup-PostID: {8B1FCBF4-9ECC-4A44-AC55-8EC6E11003AA}
| | X-MS-CommunityGroup-ThreadID: 5AE30215-24F1-48F9-B9EC-16707DAD2F45
| | X-MS-CommunityGroup-ParentID: FED06D18-3C27-46FE-A8F1-D1E348B75CFC
| | Newsgroups: microsoft.public.dotnet.framework.aspnet
| | Path: TK2MSFTNGHUB02.phx.gbl
| | Xref: TK2MSFTNGHUB02.phx.gbl
| microsoft.public.dotnet.framework.aspnet:76742
| | NNTP-Posting-Host: TK2MSFTNGHUB02.phx.gbl 127.0.0.1
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| |
| | Thanks,
| | Have you seen message from Bruce ?
| |
| | Regards
| | CS
| | "Allen Chen [MSFT]" <v-******@online.microsoft.coma écrit dans le
| message
| | de news:Ft**************@TK2MSFTNGHUB02.phx.gbl...
| | Hi,
| | >
| | I've tested Scott's project:
| | >
http://www.scottgu.com/blogposts/url...ttpModule1.zip
| | >
| | It works fine. Could you try it again to see if it works? Firstly
| please
| | view the page Default.aspx. Then click a link on the page to view
| | Products.aspx. View source of Products.aspx and you will see the
| action
| | attribute in the form tag:
| | <form name="form1" method="post" action="/SOS/Products.aspx"
| id="form1">
| | >
| | Regards,
| | Allen Chen
| | Microsoft Online Support
| | >
| | Delighting our customers is our #1 priority. We welcome your
comments
| and
| | suggestions about how we can improve the support we provide to you.
| Please
| | feel free to let my manager know what you think of the level of
| service
| | provided. You can send feedback directly to my manager at:
| | ms****@microsoft.com.
| | >
| | ==================================================
| | Get notification to my posts through email? Please refer to
| | >
| >
http://msdn.microsoft.com/en-us/subs...#notifications.
| | >
| | Note: The MSDN Managed Newsgroup support offering is for non-urgent
| issues
| | where an initial response from the community or a Microsoft Support
| | Engineer within 1 business day is acceptable. Please note that each
| follow
| | up response may take approximately 2 business days as the support
| | professional working with you may need further investigation to
reach
| the
| | most efficient resolution. The offering is not appropriate for
| situations
| | that require urgent, real-time or phone-based interactions or
complex
| | project analysis and dump analysis issues. Issues of this nature are
| best
| | handled working with a dedicated Microsoft Support Engineer by
| contacting
| | Microsoft Customer Support Services (CSS) at
| | >
| >
http://support.microsoft.com/select/...tance&ln=en-us.
| | ==================================================
| | This posting is provided "AS IS" with no warranties, and confers no
| | rights.
| | >
| | --------------------
| | | From: "WT" <WT@newsgroups.nospam>
| | | Subject: ControlAdapter sample from Scott Gu no more work ?
| | | Date: Wed, 24 Sep 2008 18:42:32 +0200
| | | Lines: 85
| | | Message-ID: <5A**********************************@microsoft.co m>
| | | MIME-Version: 1.0
| | | Content-Type: text/plain;
| | | format=flowed;
| | | charset="iso-8859-1";
| | | reply-type=original
| | | Content-Transfer-Encoding: 7bit
| | | X-Priority: 3
| | | X-MSMail-Priority: Normal
| | | X-Newsreader: Microsoft Windows Mail 6.0.6001.18000
| | | X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049
| | | X-MS-CommunityGroup-MessageCategory:
| | {E4FCE0A9-75B4-4168-BFF9-16C22D8747EC}
| | | X-MS-CommunityGroup-PostID: {5AE30215-24F1-48F9-B9EC-16707DAD2F45}
| | | Newsgroups: microsoft.public.dotnet.framework.aspnet
| | | Path: TK2MSFTNGHUB02.phx.gbl
| | | Xref: TK2MSFTNGHUB02.phx.gbl
| | microsoft.public.dotnet.framework.aspnet:76663
| | | NNTP-Posting-Host: TK2MSFTNGHUB02.phx.gbl 127.0.0.1
| | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| | |
| | | Hello,
| | |
| | | Using url rewritting and ajax.net, I tried to circumvent some
| potential
| | | problems with postback url using a code from a sample given by
| Scott.
| | | The idea is to use a control Adapter on htmlform to catch the
| attribute
| | | 'action' wich contains the url where the post will occur and
replace
| it
| | with
| | | a safe url.
| | | Unfortunately, it doesn't works, does something has changed with
| | framework
| | | 3.5 used by vs2008 ?
| | | From the trace I put inside I can see that the adapter is working
| but
| I
| | | never get an attribute named action ????
| | |
| | | Here is the code:
| | |
| | | public class FormRewriterControlAdapter : ControlAdapter
| | | {
| | | protected override void
Render(System.Web.UI.HtmlTextWriter
| | writer)
| | | {
| | | base.Render(new RewriteFormHtmlTextWriter(writer));
| | | }
| | | }
| | |
| | | public class RewriteFormHtmlTextWriter : HtmlTextWriter
| | | {
| | | public RewriteFormHtmlTextWriter(HtmlTextWriter writer)
| | | : base(writer)
| | | {
| | | InnerWriter = writer.InnerWriter;
| | | }
| | |
| | | public RewriteFormHtmlTextWriter(TextWriter writer)
| | | : base(writer)
| | | {
| | | InnerWriter = writer;
| | | }
| | |
| | | /// <summary>
| | | /// If the attribute we are writing is the "action"
| attribute,
| | and
| | | we are not on a sub-control,
| | | /// then replace the value to write with the raw URL of
the
| | | request - which ensures that we'll
| | | /// preserve the PathInfo value on postback scenarios
| | | /// </summary>
| | | public override void AddAttribute(string name, string
value,
| | bool
| | | fEncode)
| | | {
| | | HttpContext Context =
| | | HttpContext.Current;
| | | if ( name.Equals("action") )
| | | {
| | | if (Context != null &&
| | Context.Items["ActionAlreadyWritten"]
| | | == null)
| | | {
| | | value =
| | | Context.Request.RawUrl;
| | | // Indicate that we've already rewritten the
| | <form>'s
| | | action attribute to prevent
| | | // us from rewriting a sub-control under the
| <form>
| | | control
| | | Context.Items["ActionAlreadyWritten"] =
| true;
| | | }
| | | }
| | | base.AddAttribute(name, value, fEncode);
| | | }
| | |
| | | }
| | |
| | | I have also a special declaration in my web site Form_Browsers
| folder
| | |
| | | <browsers>
| | | <browser refID="Default">
| | | <controlAdapters>
| | | <adapter controlType="System.Web.UI.HtmlControls.HtmlForm"
| | |
adapterType="AddonNice.Core.UI.Adapters.FormRewrit erControlAdapter"
| />
| | | </controlAdapters>
| | | </browser>
| | | </browsers>
| | |
| | |
| | |
| | | Thanks to any help on this, it is so simple that the error must be
| | | evident.....but.
| | |
| | | CS
| | |
| | |
| | >
| |
| |
| >
|
|

Oct 2 '08 #7

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

Similar topics

1
by: aK | last post by:
hi, i'd like to play around with my 9i on RH linux 7.3 and wanted to know if there are sample db/data i can download. thanks
6
by: Daniel Rimmelzwaan | last post by:
I want to send a biztalk document to an aspx page, and I need to see some sample code, because I just can't make it work. I have a port with transport type HTTP, pointing to my aspx page, something...
2
by: Dan | last post by:
I'm trying to install the Fitch and Mather sample app and I get a dialog that says I need .NET SDK 1.0.2914. I've installed .NET SDK 1.1 and I'm still getting this message. Can anyone help?
3
by: Luigi Corrias | last post by:
Hi, where i can find good sample code for asp.net beta 2?? I have download Visual studio web express and want start to play... many many thanks Luigi
4
by: Scott Lezberg \(Deltek\) | last post by:
Does anyone have some sample code that can validate a domain username and password account to check to see if it is a valid account? Thanks in advance. Scott
4
by: news.microsoft.com | last post by:
public cFileName As String * MAX_PATH public cAlternate As String * 14 -- Scott Emick Web Programmer Fox International Remove the ham from mail address if it's not spam
1
by: Scott Haner via DotNetMonster.com | last post by:
Hey; I've done a decent amount of VB.net in University, but the next stage for a major project we have been asked to use 'modulization' and that the judges want to see as much code and functions...
2
by: Scott Townsend | last post by:
I'm looking for some sample code to listen on a TCP port. Somerthing like an Echo service would be great. Thank you, Scott<-
17
by: Ankur Arora | last post by:
Hi All, I'm building a sample application that uses a custom auto_ptr implementation. The program crashes with the following output:- Output (Debug Assertion failed) ----------
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.