Tuesday, October 18, 2011

Option Strict Discrepancy

I have run into programs where I have made a change and when I recompile them, I get a message similar to "Option Strict On disallows conversion from x to y".
The problem is the program has always been this way, and now the Option Strict On is getting invoked at some point that it had not been invoked in the past. I tried setting the Option Strict Off in the Project Properties. I also added an OPTION STRICT OFF to the top of the program. But the compiler was still using the "OPTION STRICT ON" directive.

The first time I ran into the problem, I just fixed to program to work with Option Strict ON. But then I ran into similar program fragments and decided to try and figure out where the problem was.
I found that the programName.aspx.designer.vb file had an OPTION STRICT ON which took precedence over the Source File OPTION STRICT OFF line. Change the programName.aspx.designer.vb to OPTION STRICT OFF and the program compiles as it always has.
Now I don't know how the designer is getting changed, but at least I know where to look when this occurs in the future.

Wednesday, October 12, 2011

Setting OutputCache in Web.Config

<outputCache enableOutputCache="true|false" 
             enableFragmentCache="true|false" 
             sendCacheControlHeader="true|false" 
             omitVaryStar="true|false"
             defaultProvider="AspNetInternalProvider">
</outputCache>

Tuesday, October 11, 2011

Using Request.InputStream multiple times in .Net program

I wanted to use the Request.Inputstream for multiple things in a program, but when I went to use it the second time, nothing was returned. I found you need to set the position parm to zero, before using the Request.InputStream on subsequent calls.

Example:

dim inXML as string
inXML=Request.InputStream

dim inXML2 as string
Request.Inputstream.Position=0
inXML2 =Request.InputStream

The second variable will contain the same thing as the first.