Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 11th, 2010, 08:48 PM
Authorized User
 
Join Date: Apr 2010
Posts: 15
Thanks: 8
Thanked 0 Times in 0 Posts
Smile Disable Request Validation

Hey all!
In page 315 (Chapter 9-Validating User Input) there is the following code:

Code:
if (Page.IsValid)
{
// OK to proceed
}
I don't understand when should this code be in the application?

One other thing if that's OK: I try to add the
Code:
ValidateRequest="False"
to the @Page directive, but still get the error page in the browser, when i enter HTML tag into a textbox, are there any other settings i should check?
By looking some in Google, i read that some other files should also be changed, such as web.config, any way, I'm not sure about it, so I'm asking here...

10x in advance people!
 
Old September 12th, 2010, 03:29 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You should use that as a wrapper around code that does something with the data such as saving it in the database, sending an e-mail and so on. When IsValid is true, it's safe to continue. When it isn't you could have no else block (e.g. just don't execute the action) and let ASP.NET rerender the page with validation controls. Alternatively, you could execute some other action in the else block, like a redirect, or show an additional message or whatever makes sense to do.

And yes, for .NET 4 you also need to set the requestValidationMode in web.config like this:

Code:
 
<system.web>
  <httpRuntime requestValidationMode="2.0"/>
  ...
</system.web>
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
stormage (September 12th, 2010)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 9 and 316pages,Request Validation finkle BOOK: Beginning ASP.NET 4 : in C# and VB 5 July 26th, 2010 04:00 AM
request forwarging & request redirection hafizmuhammadmushtaq Servlets 2 April 24th, 2008 12:42 AM
Request.Form / Request.QueryString Toran Classic ASP Databases 4 January 17th, 2007 02:23 PM
request.qurystring vs. request.form Durwood Edwards Classic ASP Databases 3 June 18th, 2004 12:09 AM
request.querystring() , request.form() alyeng2000 ASP.NET 1.0 and 1.1 Basics 1 December 30th, 2003 12:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.