Re: ControlAdapter sample from Scott Gu no more work ?



Yes I am using the 3.5 SP1.
I try your code and give a feed-back, thanks.
CS

"Allen Chen [MSFT]" <v-alchen@xxxxxxxxxxxxxxxxxxxx> a écrit dans le message de news:SpCOav4HJHA.5708@xxxxxxxxxxxxxxxxxxxxxxxxx
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@xxxxxxxxxxxxxxxxx>
| References: <5AE30215-24F1-48F9-B9EC-16707DAD2F45@xxxxxxxxxxxxx>
<FtL19UtHJHA.6004@xxxxxxxxxxxxxxxxxxxxxx>
| In-Reply-To: <FtL19UtHJHA.6004@xxxxxxxxxxxxxxxxxxxxxx>
| Subject: Re: ControlAdapter sample from Scott Gu no more work ?
| Date: Thu, 25 Sep 2008 16:46:52 +0200
| Lines: 168
| Message-ID: <8B1FCBF4-9ECC-4A44-AC55-8EC6E11003AA@xxxxxxxxxxxxx>
| 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-alchen@xxxxxxxxxxxxxxxxxxxx> a écrit dans le
message
| de news:FtL19UtHJHA.6004@xxxxxxxxxxxxxxxxxxxxxxxxx
| > Hi,
| >
| > I've tested Scott's project:
| > http://www.scottgu.com/blogposts/urlrewrite/UrlRewrite_HttpModule1.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:
| > msdnmg@xxxxxxxxxxxxxx
| >
| > ==================================================
| > Get notification to my posts through email? Please refer to
| >
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#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/default.aspx?target=assistance&ln=en-us.
| > ==================================================
| > This posting is provided "AS IS" with no warranties, and confers no
| > rights.
| >
| > --------------------
| > | From: "WT" <WT@xxxxxxxxxxxxxxxxx>
| > | Subject: ControlAdapter sample from Scott Gu no more work ?
| > | Date: Wed, 24 Sep 2008 18:42:32 +0200
| > | Lines: 85
| > | Message-ID: <5AE30215-24F1-48F9-B9EC-16707DAD2F45@xxxxxxxxxxxxx>
| > | 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.FormRewriterControlAdapter" />
| > | </controlAdapters>
| > | </browser>
| > | </browsers>
| > |
| > |
| > |
| > | Thanks to any help on this, it is so simple that the error must be
| > | evident.....but.
| > |
| > | CS
| > |
| > |
| >
|
|


.



Relevant Pages

  • RE: Backups, VSS and SBS2003 HELP NEEDED!!!
    ... 2K3 server currently, also, I understand that it is better to have a backup ... Support Professional can assist with your request. ... Microsoft CSS Online Newsgroup Support ... >> suggest customers Only install Windows Server 2003 SP1 on their server. ...
    (microsoft.public.windows.server.sbs)
  • Re: MovieMaker Security Suite 2005 Case #: SRX050223602463
    ... I was impressed by the performance Microsoft ... > Review of MovieMaker Security, ... Telephonte Support replied with a non-existant answer to the ... > regarding my service, Zee Awad, my manager, would be very happy to hear ...
    (microsoft.public.windowsxp.moviemaker)
  • RE: 2000 AS SP4 RepositoryUser and OLAP Admins Group
    ... Thank you for using Microsoft Managed TechNet Newsgroup. ... Administrators group to the database role RepositoryUser for msdb. ... Open SQL Server Enterprise Manager, expand Security folder, right click Logins, click ... Microsoft Online Community Support ...
    (microsoft.public.sqlserver.olap)
  • RE: Replication Status Error fffffc07
    ... Dismount the problematic public folder store through Exchange System ... please refer to the following Microsoft ... Microsoft Online Partner Support ... >When I use Exchange System Manager to see Replication Status ...
    (microsoft.public.exchange2000.admin)
  • Re: Ajax on .NET 2.0
    ... Please try to create a new ASP.NET AJAX-Enabled Web Site. ... Microsoft Online Support ... You can send feedback directly to my manager at: ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet)

Loading