473,503 Members | 2,435 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ValidateRequest bug?

Ok, I have a global page class derived from System.Web.UI.Page, let's call
it BasePage. I have another class derived from that called MemberPage. It
checks the Form collection if it's a post for some "common" fields.

Now, I have an aspx page whose code behind derives from BasePage, and which
sets ValidateRequest=False in the page directive of the aspx. I can post
<script> tags and such with no problems.

However, when I make the code-behind derive from MemberPage, it throws an
exception in ValidateRequest for the Form collection *EVEN THOUGH
VALIDATEREQUEST IS FALSE*.

I don't understand how this could possibly be correct behavior?
Nov 18 '05 #1
8 1848
Max,

This might be annoying, but it's not a bug. The subclassing of BasePage by
MemberPage includes only the code, not the page directive. If you don't
want request validation to be active for any given page, you must specify
this in the page directive for that page.

HTH,
Nicole

"Max Metral" <me******@hotmail.com> wrote in message
news:tI********************@speakeasy.net...
Ok, I have a global page class derived from System.Web.UI.Page, let's call
it BasePage. I have another class derived from that called MemberPage.
It checks the Form collection if it's a post for some "common" fields.

Now, I have an aspx page whose code behind derives from BasePage, and
which sets ValidateRequest=False in the page directive of the aspx. I can
post <script> tags and such with no problems.

However, when I make the code-behind derive from MemberPage, it throws an
exception in ValidateRequest for the Form collection *EVEN THOUGH
VALIDATEREQUEST IS FALSE*.

I don't understand how this could possibly be correct behavior?

Nov 18 '05 #2
Makes sense, but the hierarchy is as follows:

System.Web.UI.Page->BasePage->MemberPage->MyASPXCodeBehind->MyASPX

ValidateRequest is False in MyASPX, so it should be false right?

And to be clear, with absolutely NO other changes, this works fine:

System.Web.UI.Page->BasePage->MyASPXCodeBehind->MyASPX

Furthermore, all but the MyASPX are cs classes, and I don't even see a way
to specify the ValidateRequest directive for cs files, so I don't see how
MemberPage could be doing it.

"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message
news:ub*************@tk2msftngp13.phx.gbl...
Max,

This might be annoying, but it's not a bug. The subclassing of BasePage
by MemberPage includes only the code, not the page directive. If you
don't want request validation to be active for any given page, you must
specify this in the page directive for that page.

HTH,
Nicole

"Max Metral" <me******@hotmail.com> wrote in message
news:tI********************@speakeasy.net...
Ok, I have a global page class derived from System.Web.UI.Page, let's
call it BasePage. I have another class derived from that called
MemberPage. It checks the Form collection if it's a post for some
"common" fields.

Now, I have an aspx page whose code behind derives from BasePage, and
which sets ValidateRequest=False in the page directive of the aspx. I
can post <script> tags and such with no problems.

However, when I make the code-behind derive from MemberPage, it throws an
exception in ValidateRequest for the Form collection *EVEN THOUGH
VALIDATEREQUEST IS FALSE*.

I don't understand how this could possibly be correct behavior?


Nov 18 '05 #3
Hi Max,

From your description, when you make your aspx page's codebehind page
class dervied from a two level
custom base page class(indirectly derived from System.Web.UI.Page), the
validateRequest attribute you set in the aspx 's @page diretive not work,
yes?

Based on the page hierarchy you described as below:
==================================
System.Web.UI.Page->BasePage->MemberPage->MyASPXCodeBehind->MyASPX

System.Web.UI.Page->BasePage->MyASPXCodeBehind->MyASPX
====================================

I've also done a simple test on my side , it seems that I can't reproduce
the problem. I uses two very simple page( just derived without add any
custom code), here are the page classes I used to test:

==========================
public class MyBasePage : System.Web.UI.Page
{
public MyBasePage()
{
//
// TODO: Add constructor logic here
//
}
}

public class MyDerivedPage : MyBasePage
{
public MyDerivedPage()
{

}
}
}
=============================

And when I make a aspx page's code behind class derived from either of the
MyBasePage or MyDerivedPage, the validateRequest set in the aspx's @Page
will work. So would you please also have a try so that we can found the
actual cause? Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #4
"Max Metral" <me******@hotmail.com> wrote in message
news:n4********************@speakeasy.net...
Makes sense, but the hierarchy is as follows:

System.Web.UI.Page->BasePage->MemberPage->MyASPXCodeBehind->MyASPX

ValidateRequest is False in MyASPX, so it should be false right?
Right.

And to be clear, with absolutely NO other changes, this works fine:

System.Web.UI.Page->BasePage->MyASPXCodeBehind->MyASPX

Furthermore, all but the MyASPX are cs classes, and I don't even see a way
to specify the ValidateRequest directive for cs files, so I don't see how
MemberPage could be doing it.
Like Steven, I can't reproduce the problem. My best guess would be that the
ValidateInput method of the request object is being called either within
MemberPage or in other code (e.g.: code behind the final page, http module,
etc.) that screens for whether the requested resource derives from
MemberPage before running the validation.


"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message
news:ub*************@tk2msftngp13.phx.gbl...
Max,

This might be annoying, but it's not a bug. The subclassing of BasePage
by MemberPage includes only the code, not the page directive. If you
don't want request validation to be active for any given page, you must
specify this in the page directive for that page.

HTH,
Nicole

"Max Metral" <me******@hotmail.com> wrote in message
news:tI********************@speakeasy.net...
Ok, I have a global page class derived from System.Web.UI.Page, let's
call it BasePage. I have another class derived from that called
MemberPage. It checks the Form collection if it's a post for some
"common" fields.

Now, I have an aspx page whose code behind derives from BasePage, and
which sets ValidateRequest=False in the page directive of the aspx. I
can post <script> tags and such with no problems.

However, when I make the code-behind derive from MemberPage, it throws
an exception in ValidateRequest for the Form collection *EVEN THOUGH
VALIDATEREQUEST IS FALSE*.

I don't understand how this could possibly be correct behavior?



Nov 18 '05 #5
The one difference in your tests is that you need to call something like:

if (Request.Form["foo"] = "bar")
Trace.Write("Yo");

in the page_load or onload of MemberPage. It's during that call that it
seems to call Validate.

"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message
news:OV**************@TK2MSFTNGP10.phx.gbl...
"Max Metral" <me******@hotmail.com> wrote in message
news:n4********************@speakeasy.net...
Makes sense, but the hierarchy is as follows:

System.Web.UI.Page->BasePage->MemberPage->MyASPXCodeBehind->MyASPX

ValidateRequest is False in MyASPX, so it should be false right?


Right.

And to be clear, with absolutely NO other changes, this works fine:

System.Web.UI.Page->BasePage->MyASPXCodeBehind->MyASPX

Furthermore, all but the MyASPX are cs classes, and I don't even see a
way to specify the ValidateRequest directive for cs files, so I don't see
how MemberPage could be doing it.


Like Steven, I can't reproduce the problem. My best guess would be that
the ValidateInput method of the request object is being called either
within MemberPage or in other code (e.g.: code behind the final page, http
module, etc.) that screens for whether the requested resource derives from
MemberPage before running the validation.


"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message
news:ub*************@tk2msftngp13.phx.gbl...
Max,

This might be annoying, but it's not a bug. The subclassing of BasePage
by MemberPage includes only the code, not the page directive. If you
don't want request validation to be active for any given page, you must
specify this in the page directive for that page.

HTH,
Nicole

"Max Metral" <me******@hotmail.com> wrote in message
news:tI********************@speakeasy.net...
Ok, I have a global page class derived from System.Web.UI.Page, let's
call it BasePage. I have another class derived from that called
MemberPage. It checks the Form collection if it's a post for some
"common" fields.

Now, I have an aspx page whose code behind derives from BasePage, and
which sets ValidateRequest=False in the page directive of the aspx. I
can post <script> tags and such with no problems.

However, when I make the code-behind derive from MemberPage, it throws
an exception in ValidateRequest for the Form collection *EVEN THOUGH
VALIDATEREQUEST IS FALSE*.

I don't understand how this could possibly be correct behavior?



Nov 18 '05 #6
Still doesn't reproduce here. Are you perhaps using a trace listener that
might be calling ValidateRequest on the request?

"Max Metral" <me******@hotmail.com> wrote in message
news:9u********************@speakeasy.net...
The one difference in your tests is that you need to call something like:

if (Request.Form["foo"] = "bar")
Trace.Write("Yo");

in the page_load or onload of MemberPage. It's during that call that it
seems to call Validate.

"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message
news:OV**************@TK2MSFTNGP10.phx.gbl...
"Max Metral" <me******@hotmail.com> wrote in message
news:n4********************@speakeasy.net...
Makes sense, but the hierarchy is as follows:

System.Web.UI.Page->BasePage->MemberPage->MyASPXCodeBehind->MyASPX

ValidateRequest is False in MyASPX, so it should be false right?


Right.

And to be clear, with absolutely NO other changes, this works fine:

System.Web.UI.Page->BasePage->MyASPXCodeBehind->MyASPX

Furthermore, all but the MyASPX are cs classes, and I don't even see a
way to specify the ValidateRequest directive for cs files, so I don't
see how MemberPage could be doing it.


Like Steven, I can't reproduce the problem. My best guess would be that
the ValidateInput method of the request object is being called either
within MemberPage or in other code (e.g.: code behind the final page,
http module, etc.) that screens for whether the requested resource
derives from MemberPage before running the validation.


"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message
news:ub*************@tk2msftngp13.phx.gbl...
Max,

This might be annoying, but it's not a bug. The subclassing of
BasePage by MemberPage includes only the code, not the page directive.
If you don't want request validation to be active for any given page,
you must specify this in the page directive for that page.

HTH,
Nicole

"Max Metral" <me******@hotmail.com> wrote in message
news:tI********************@speakeasy.net...
> Ok, I have a global page class derived from System.Web.UI.Page, let's
> call it BasePage. I have another class derived from that called
> MemberPage. It checks the Form collection if it's a post for some
> "common" fields.
>
> Now, I have an aspx page whose code behind derives from BasePage, and
> which sets ValidateRequest=False in the page directive of the aspx. I
> can post <script> tags and such with no problems.
>
> However, when I make the code-behind derive from MemberPage, it throws
> an exception in ValidateRequest for the Form collection *EVEN THOUGH
> VALIDATEREQUEST IS FALSE*.
>
> I don't understand how this could possibly be correct behavior?
>



Nov 18 '05 #7
I was tracing to the page, is this not allowed?

"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message
news:ec**************@TK2MSFTNGP10.phx.gbl...
Still doesn't reproduce here. Are you perhaps using a trace listener that
might be calling ValidateRequest on the request?

"Max Metral" <me******@hotmail.com> wrote in message
news:9u********************@speakeasy.net...
The one difference in your tests is that you need to call something like:

if (Request.Form["foo"] = "bar")
Trace.Write("Yo");

in the page_load or onload of MemberPage. It's during that call that it
seems to call Validate.

"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message
news:OV**************@TK2MSFTNGP10.phx.gbl...
"Max Metral" <me******@hotmail.com> wrote in message
news:n4********************@speakeasy.net...
Makes sense, but the hierarchy is as follows:

System.Web.UI.Page->BasePage->MemberPage->MyASPXCodeBehind->MyASPX

ValidateRequest is False in MyASPX, so it should be false right?

Right.
And to be clear, with absolutely NO other changes, this works fine:

System.Web.UI.Page->BasePage->MyASPXCodeBehind->MyASPX

Furthermore, all but the MyASPX are cs classes, and I don't even see a
way to specify the ValidateRequest directive for cs files, so I don't
see how MemberPage could be doing it.

Like Steven, I can't reproduce the problem. My best guess would be that
the ValidateInput method of the request object is being called either
within MemberPage or in other code (e.g.: code behind the final page,
http module, etc.) that screens for whether the requested resource
derives from MemberPage before running the validation.

"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message
news:ub*************@tk2msftngp13.phx.gbl...
> Max,
>
> This might be annoying, but it's not a bug. The subclassing of
> BasePage by MemberPage includes only the code, not the page directive.
> If you don't want request validation to be active for any given page,
> you must specify this in the page directive for that page.
>
> HTH,
> Nicole
>
>
>
> "Max Metral" <me******@hotmail.com> wrote in message
> news:tI********************@speakeasy.net...
>> Ok, I have a global page class derived from System.Web.UI.Page, let's
>> call it BasePage. I have another class derived from that called
>> MemberPage. It checks the Form collection if it's a post for some
>> "common" fields.
>>
>> Now, I have an aspx page whose code behind derives from BasePage, and
>> which sets ValidateRequest=False in the page directive of the aspx.
>> I can post <script> tags and such with no problems.
>>
>> However, when I make the code-behind derive from MemberPage, it
>> throws an exception in ValidateRequest for the Form collection *EVEN
>> THOUGH VALIDATEREQUEST IS FALSE*.
>>
>> I don't understand how this could possibly be correct behavior?
>>
>
>



Nov 18 '05 #8
Hi Max,

Thanks for the followup. What's has been done in your page tracer? As far
as what we can find now, this is the only possible cause. you can try
removing the tracing to see whether it works.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #9

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

Similar topics

1
20703
by: mar | last post by:
Does anybody know what configuration section should i set to false here. I also tried setting the page directive to false but that didn't fix it. Thanks! mc A potentially dangerous...
1
3214
by: Shaun Dore | last post by:
Hi, I have a web form containing a TextBox that allows users to edit XML files. When the page is posted, the changes are saved. This worked fine until the ValidateRequest 'feature' came along in...
1
1329
by: Benny | last post by:
Hello Experts, If the contents of a text box containing a html tag like formmated characters, i.e. <hello>, and if the validateRequest is set to true, it gives an error when post back: A...
4
6357
by: Ray Williams | last post by:
I have a specific page that I have chosen to disable the .NET 1.1 validateRequest options by setting the page directive attribute of "validateRequest" from true to false. I manually validate all...
2
15873
by: Tim Zych | last post by:
I'm trying to stop .Net from validating data entered into a textbox. When I enter < or > .Net returns an error: potentially dangerous Request.Form value was detected from the client... so a...
2
2990
by: Andy Fish | last post by:
Hi, I have one textbox on the form that needs to have ValidateRequest disabled, but it seems that it can only be enabled/disabled at a page level. assuming I have to disable it at for the...
3
2090
by: Umut Tezduyar | last post by:
I couln't find the code begind property on the Page object that represents the "ValidateRequest" attribute on the @Page element. There must be some property that the PageParser knows what to do...
4
2136
by: Dave H | last post by:
If put this into my Web.config. Shouldn't this turn off the ValiateRequest app wide? <configuration> <system.web> <pages buffer="true" validateRequest="false" /> I pass SQL around to...
2
2050
by: \A_Michigan_User\ | last post by:
*WITHOUT* using: ValidateRequest="False" for the whole page (or my whole site).... How would I trap/detect that a textBox contains some illegal characters? (I'm using asp.net v1.1 and vb.net)...
0
7188
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,...
0
7063
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...
1
6970
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
4663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
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...
0
3146
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1489
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 ...
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
366
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...

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.