Saturday, June 18, 2011

I spent over three weeks looking for a solution.. this was driving me crazy.

I had a website developed in ASP.NET 2.0 a few years back and deployed it on a server I paid for (Webhostforasp.net).. All of a sudden about a month back, all text boxes across the pages of my website started throwing this error

"A potentially dangerous Request.Form value was detected from the client (ctl00$cphAdmin$txtContent$TinyMCE1$txtContent="

I tried everything including putting in my web.config file but it did not work till I found the trick I was missing..

Unknown to me my server provider had updated his server to be compatible with ASP.NET 4.0 which had stricter entry rules AND did not recognize pages validateRequest = false statement in web.config... solution is simple

Step 1. Within your web.config file under system.web
< system.web >
< pages validaterequest="false" / >

< /system.web>

Step 2. Within your web.config file under system.web
< system.web >
< httpruntime requestvalidationmode="2.0" / >
< /system.web >


This worked for me and hope it works for you as well...

Sunday, February 15, 2009

ASP.NET Online Exam System

I worked quite a bit on the asp.net online examination code 
(original source code http://dotnet.tekyt.info/?p=34)

Changes added
1) Add configurable parameter for Total No of Questions in the pool and Number of questions to display

2) Change database from mysql to Sql Server 2005 express

3) Enabled/Disabled previous and next buttons and Show final marks button

4) Fixed issue with the Timer - it wasn’t displaying for me

5) Added pieces of code to email the score of the online test as well as store the score in a database table

6) Several other small enhancements/fixes to make it work better and bug free
Code has been uploaded here


Installation and configuration

1. You may need a bit of effort to pore through the code

Some info might help

  • The online examination is under RAT folder of your root  (there are two web.config file, one should be under the root director and other under RAT folder)
  • Put in database server info, username, password etc in the web.config (of the root folder)
  • Put in smtp mail info as per your website host
2. I have added a module whereby depending upon no of correct answers, a scholarship email will be sent to the entrant (you can create any webpage, and specify the link in the code whereby the whole webpage can be sent via email)

3. The default.aspx page is made such that depending upon the user authenticated (username: admin can give the test any number of times) and others (if given earlier - will not be allowed to give again)

All source code is there - feel free to modify and understand. For any questions, you are welcome to comment or email me






Monday, October 27, 2008

Sys.Webforms.PageRequestManagerServerErrorException: ... status code returned from the server was: 0

I had tried almost everything in the world but it didn't solve the error. My issue was

1) Getting the error only in firefox
2) Getting it only on remote server not on localhost

I could only fix it by

Adding the below line of codes (just change the status code to what you were getting, I had status code error 0)






This code needs to be added in your designer page .. e.g



/*Add above code here*/




Sunday, January 21, 2007

INSTALL IIS BEFORE VISUAL STUDIO !!!!!!!

This is the second time I have spent more than three hours trying to solve some unconnected problem and the solution turned out to be same. Always and always, install IIS before Visual Studio. And if you do happen to

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis.exe -i

This will solve the problem .

Friday, September 01, 2006

Regular Expressions

Few sites can explain regular expressions so well. Magical !

http://www.regular-expressions.info/tutorial.html

Monday, August 28, 2006

Notes on VB.NET

1. System.object is the base class for all data types.
2. Reference types derive directly from system.object
3. value types derive from system.valuetype which in turn derives from system.object
4. system.boolean takes up 1 byte
5. system.char takes up 2 bytes
6. Double takes up 8 bytes
7. system.string is a reference type
8. All reference types or objects are managed by the GC on the GC heap.
9. If you attempt to perform an operation against a null, you'll ordinarily receive a
NullReferenceException in response
10. value types can store on the execution stack or on the heap managed by the GC
11. value types cannot have parameterless constructors
12. use sizeof(T) to find size of a value type
13. datetime is a value type
14. private is the default visibility type for MEMBERS
15. assemblty is the default visibility for TYPES
16. shared members can only access other shared members belonging to the same type and not to any instance members. Not true vice versa.
17. by default int x is 4 bytes
18. constant fields are shared by default since all instances of the class have the same value.
19, shared methods have no me pointer
20. byval is default
21. all methods in vb.net are virtual by default.
22. A virtual method is one which can be overrided
22. methods must declare them to be overridable (not default) to allow base classes to change their implementation
22. shadow variable is a local variable within a function with the same name as a member variable of the type class
23. system.gc.collect() manually triggers garbage collection
24. The Exception is the ultimate base class for any exceptions in VB.NET
25. Environment.Systemdirectory is used to return a string to the windows folder
26. Encoding.ASCII.GetBytes("hi rochak") to convert string to a bytearray.
27. closing the stremwriter causes the data to be flushed, but doing so will also close the underlying stream

Saturday, August 26, 2006

Generics

Excellent article on 15seconds on generics... the new feature in .NET 2.0 Must read.

http://www.15seconds.com/issue/040525.htm




Events And Delegates

Probably one of the best sites

http://abstractvb.com/code.asp?A=1084