Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 11th, 2010, 08:48 PM
Authorized User
Points: 77, Level: 1
Points: 77, Level: 1 Points: 77, Level: 1 Points: 77, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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!
Reply With Quote
  #2 (permalink)  
Old September 12th, 2010, 03:29 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
stormage (September 12th, 2010)
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:51 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.