<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Victor Feinman &#187; Technology</title>
	<atom:link href="http://www.victorfeinman.com/category/technology/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.victorfeinman.com</link>
	<description>I found it on some guy&#039;s site</description>
	<lastBuildDate>Wed, 26 Oct 2011 00:02:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Verifying or asserting JavaScript objects in Selenium IDE</title>
		<link>http://www.victorfeinman.com/2011/05/verifying-or-asserting-javascript-objects-in-selenium-ide/</link>
		<comments>http://www.victorfeinman.com/2011/05/verifying-or-asserting-javascript-objects-in-selenium-ide/#comments</comments>
		<pubDate>Thu, 19 May 2011 18:41:49 +0000</pubDate>
		<dc:creator>Some Guy</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[assertEval]]></category>
		<category><![CDATA[Automation]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[selenium ide]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[test automation]]></category>
		<category><![CDATA[verifyEval]]></category>

		<guid isPermaLink="false">http://www.victorfeinman.com/?p=197</guid>
		<description><![CDATA[For all of you who do not know what Selenium is… “…a Firefox add-on that records clicks, typing, and other actions to make a test, which you can play back in the browser.” – www.seleniumhq.org It’s not too difficult to do at all, just not documented. Maybe because I should already know this and the [...]]]></description>
			<content:encoded><![CDATA[<p>For all of you who do not know what Selenium is…</p>
<p>“…a Firefox add-on that records clicks, typing, and other actions to make a test, which you can play back in the browser.” – <a href="http://www.seleniumhq.org">www.seleniumhq.org</a> </p>
<p>It’s not too difficult to do at all, just not documented. Maybe because I should already know this and the selenium community is mocking me, or maybe because it just lacks documentation. So at the risk of sounding like a noob here’s how to verify JavaScritpt objects exists in Selenium. </p>
<p>Command: verifyEval    <br />Target: this.browserbot.getUserWindow().eMVC.models['global']     <br />Value: *Object* </p>
<p><a href="http://www.victorfeinman.com/wp-content/uploads/2011/05/image.png" rel="lightbox"><img style="border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.victorfeinman.com/wp-content/uploads/2011/05/image_thumb.png" width="524" height="173" /></a></p>
<p>this.browserbot.getUserWindow() gets the current window object. The “Value” or pattern matches the text representation of the object. For example, when you do alert(someObject), you get this: [object Object]; that is what your pattern is matching. </p>
<span class="akst_link"><a href="http://www.victorfeinman.com/?p=197&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_197">Share This</a>
</span><div class='diggWrap'><script type='text/javascript'>
<!--
digg_url='http://www.victorfeinman.com/2011/05/verifying-or-asserting-javascript-objects-in-selenium-ide/';
digg_skin = 'compact';
digg_bgcolor = '#ffffff';
digg_title = 'Verifying or asserting JavaScript objects in Selenium IDE';
digg_bodytext = '';
digg_topic = '';
//-->
</script>
<script type='text/javascript' src='http://digg.com/tools/diggthis.js'></script>
</div>
<div class='share'><span class="akst_link"><a href="http://www.victorfeinman.com/?p=197&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_197">Share This</a>
</span></div>
<br class='clear' />]]></content:encoded>
			<wfw:commentRss>http://www.victorfeinman.com/2011/05/verifying-or-asserting-javascript-objects-in-selenium-ide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting cookies on the same response as a redirect in C#</title>
		<link>http://www.victorfeinman.com/2011/05/setting-cookies-on-the-same-response-as-a-redirect-in-c/</link>
		<comments>http://www.victorfeinman.com/2011/05/setting-cookies-on-the-same-response-as-a-redirect-in-c/#comments</comments>
		<pubDate>Fri, 06 May 2011 14:38:34 +0000</pubDate>
		<dc:creator>Some Guy</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Cookies]]></category>
		<category><![CDATA[Redirect]]></category>
		<category><![CDATA[SetCookie]]></category>

		<guid isPermaLink="false">http://www.victorfeinman.com/?p=176</guid>
		<description><![CDATA[If you are trying to set a cookie and then using Response.Redirect and it's not working, no worries some guy is here to help! I've recently had this issue when I needed to set a cookie before redirecting to a login page. However, I needed to do this with only one response. The only way [...]]]></description>
			<content:encoded><![CDATA[<p>If you are trying to set a cookie and then using Response.Redirect and it's not working, no worries some guy is here to help!</p>
<p>I've recently had this issue when I needed to set a cookie before redirecting to a login page. However, I needed to do this with only one response. The only way I knew how to add a cookie to the cookie collection is by calling the Response.Cookies.Add method passing an HttpCookie object. I tried this, but much to my dismay the set cookie header was missing.</p>
<p>I found an alternate method of adding a cookie to the response and it's naughty. Use the HttpResponse.SetCookie method instead - that's it. And by naughty I mean Microsoft doesn't recommend using it. They say, "This API supports the .NET Framework infrastructure and is not intended to be used directly from your code." <a title="HttpResponse.SetCookie" href="http://msdn.microsoft.com/en-us/library/system.web.httpresponse.setcookie.aspx" target="_blank">here</a>.</p>
<p>New working code looks like this:</p>
<pre class="brush:csharp">    HttpCookie cookie = new HttpCookie("HostName", WebUtil.GetServerUrl(true));
    cookie.Domain = "yourdomain.com";
    cookie.Path = "/";
    HttpContext.Current.Response.SetCookie(cookie);
    //Redirect to login page using new url.
    base.RedirectToLoginPage(new_url);
</pre>
<span class="akst_link"><a href="http://www.victorfeinman.com/?p=176&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_176">Share This</a>
</span><div class='diggWrap'><script type='text/javascript'>
<!--
digg_url='http://www.victorfeinman.com/2011/05/setting-cookies-on-the-same-response-as-a-redirect-in-c/';
digg_skin = 'compact';
digg_bgcolor = '#ffffff';
digg_title = 'Setting cookies on the same response as a redirect in C#';
digg_bodytext = '';
digg_topic = '';
//-->
</script>
<script type='text/javascript' src='http://digg.com/tools/diggthis.js'></script>
</div>
<div class='share'><span class="akst_link"><a href="http://www.victorfeinman.com/?p=176&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_176">Share This</a>
</span></div>
<br class='clear' />]]></content:encoded>
			<wfw:commentRss>http://www.victorfeinman.com/2011/05/setting-cookies-on-the-same-response-as-a-redirect-in-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Server Side Redirect to a Sitecore Item</title>
		<link>http://www.victorfeinman.com/2011/05/server-side-redirect-to-a-sitecore-item/</link>
		<comments>http://www.victorfeinman.com/2011/05/server-side-redirect-to-a-sitecore-item/#comments</comments>
		<pubDate>Fri, 06 May 2011 13:40:00 +0000</pubDate>
		<dc:creator>Some Guy</dc:creator>
				<category><![CDATA[Sitecore]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[httpRequestBegin]]></category>
		<category><![CDATA[Pipelines]]></category>
		<category><![CDATA[Session State]]></category>

		<guid isPermaLink="false">http://www.victorfeinman.com/?p=165</guid>
		<description><![CDATA[This needs to be in the httpRequestBegin pipeline before the page starts rendering. This Solution assumes that you set the ItemNotFound setting to a Sitecore Item and the RequestErrors.UseServerSideRedirect setting is set to true in the sitecore settings section of the web.config. The problem is that Sitecore assumes that if you set RequestErrors.UseServerSideRedirect to true, you [...]]]></description>
			<content:encoded><![CDATA[<p>This needs to be in the httpRequestBegin pipeline before the page starts rendering. This Solution assumes that you set the ItemNotFound setting to a Sitecore Item and the RequestErrors.UseServerSideRedirect setting is set to true in the sitecore settings section of the web.config. The problem is that Sitecore assumes that if you set RequestErrors.UseServerSideRedirect to true, you are redirect to a physical .aspx page. If you'd like to redirect to a Sitecore Item, here is how.</p>
<p>The problem is in the PerformRedirect method in Sitecore.Pipelines.HttpRequest.ExecuteRequest class. You'll have to create a new class that inherits the ExecuteRequest class and override the PerformRedirect method. Instead of executing HttpContext.Current.Server.Transfer(url) you'll need to add some logic that will make sure the url passed is one to an Item, then you'll have to force the request through the httpRequestBegin pipeline again (actually all you really have to do is run it through the LayoutResolver process, but the only way to do this without ripping out and modifying the LayoutResolver code is to force it through the entire pipeline).</p>
<p>Code example below:</p>
<pre class="brush:csharp">    public class ExecuteRequest : Sitecore.Pipelines.HttpRequest.ExecuteRequest
    {
        protected override void PerformRedirect(string url)
        {
            if (Settings.RequestErrors.UseServerSideRedirect)
            {
                Sitecore.Web.WebUtil.RewriteUrl(url);
                Context.Item = GetItemFromUrl(url);
                if (Context.Item != null)
                {
                    HttpRequestArgs args = new HttpRequestArgs(HttpContext.Current, HttpRequestType.Begin);
                    Sitecore.Pipelines.CorePipeline.Run("httpRequestBegin", (Sitecore.Pipelines.PipelineArgs)args);
                }
            }
            else
            {
                WebUtil.Redirect(url, false);
            }
        }

        ///
        ///     Returns an Item from a URL.
        ///
        ///
<param name="url" />The url of the sitecore item.
        /// The Item the url represents.
        public static Item GetItemFromUrl(string url)
        {
            string referring_item_path = null;
            if (Uri.IsWellFormedUriString(url, UriKind.Relative))
                url = Sitecore.Web.WebUtil.GetFullUrl(url);
            if (Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                Uri uri = new Uri(url);
                if (uri.AbsolutePath.StartsWith("/sitecore/"))
                    referring_item_path = uri.AbsolutePath;
                else
                    referring_item_path = Sitecore.Context.Site.StartPath + uri.AbsolutePath;
            }
            //Remove the extension and put a '/' instead.
            referring_item_path = Regex.Replace(referring_item_path, @"(?:\.aspx|\.ashx)", "/");
            //Declare a temp return value variable.
            Item retVal = null;
            using (new Sitecore.SecurityModel.SecurityDisabler())
            {
                //Get the item based off the sitecore path.
                retVal = Sitecore.Context.Database.GetItem(referring_item_path);
            }
            //return the item.
            return retVal;
        }
    }</pre>
<p>This new class needs to replace the current process in the httpRequestBegin pipeline. That can be accomplished by placing a .config file in the /App_Config/Include directory with the following XML.</p>
<pre class="brush:xml">
<configuration xmlns:x="http://www.sitecore.net/xmlconfig/">
  <sitecore>
<pipelines>
      <httprequestbegin>
        <!--
          Replaces the existing execute request to handle the custom 404 page.
        -->
<processor type="Sitecore.Pipelines.HttpRequest.ExecuteRequest, Sitecore.Kernel">
          <x:attribute name="type">your.namespace.ExecuteRequest, yourAssembly</x:attribute>
        </processor>
    </httprequestbegin></pipelines>
  </sitecore>
</configuration>
</pre>
<p>Or if you're ok with modifying the web.config directly replace the type attribute in the below line in your web.config file.<br />
It should look like this:</p>
<p>&lt;processor type="Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel" /&gt;<br />
&lt;processor type="Sitecore.Pipelines.HttpRequest.LayoutResolver, Sitecore.Kernel" /&gt;<br />
<strong>&lt;processor type="your.namespace.ExecuteRequest, yourAssembly" /&gt;</strong></p>
<span class="akst_link"><a href="http://www.victorfeinman.com/?p=165&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_165">Share This</a>
</span><div class='diggWrap'><script type='text/javascript'>
<!--
digg_url='http://www.victorfeinman.com/2011/05/server-side-redirect-to-a-sitecore-item/';
digg_skin = 'compact';
digg_bgcolor = '#ffffff';
digg_title = 'Server Side Redirect to a Sitecore Item';
digg_bodytext = '';
digg_topic = '';
//-->
</script>
<script type='text/javascript' src='http://digg.com/tools/diggthis.js'></script>
</div>
<div class='share'><span class="akst_link"><a href="http://www.victorfeinman.com/?p=165&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_165">Share This</a>
</span></div>
<br class='clear' />]]></content:encoded>
			<wfw:commentRss>http://www.victorfeinman.com/2011/05/server-side-redirect-to-a-sitecore-item/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Server.Transfer in Sitecore</title>
		<link>http://www.victorfeinman.com/2011/05/server-transfer-in-sitecore/</link>
		<comments>http://www.victorfeinman.com/2011/05/server-transfer-in-sitecore/#comments</comments>
		<pubDate>Fri, 06 May 2011 13:19:49 +0000</pubDate>
		<dc:creator>Some Guy</dc:creator>
				<category><![CDATA[Sitecore]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[httpRequestBegin]]></category>
		<category><![CDATA[Pipelines]]></category>
		<category><![CDATA[Session State]]></category>

		<guid isPermaLink="false">http://www.victorfeinman.com/?p=150</guid>
		<description><![CDATA[If you are trying to use Server.Transfer or Server.Execute to redirect a request to a Sitecore item you can forget about it. Can't do it, not like that at least. Until I find a way to tap into Sitecores layout rendering engine, I have two solutions for you. One way, which I wouldn't recommend is [...]]]></description>
			<content:encoded><![CDATA[<p>If you are trying to use Server.Transfer or Server.Execute to redirect a request to a Sitecore item you can forget about it. Can't do it, not like that at least. Until I find a way to tap into Sitecores layout rendering engine, I have two solutions for you. One way, which I wouldn't recommend is to initiate a webrequest and output in the current response, the response of the target page. i.e.</p>
<pre class="brush:csharp smart-tabs:true">string sURL = Sitecore.Web.WebUtil.GetServerUrl(Request.Url, true) + "/404.aspx";
WebRequest wrGETURL;
wrGETURL = WebRequest.Create(sURL);
Stream objStream;
objStream = wrGETURL.GetResponse().GetResponseStream();
StreamReader objReader = new StreamReader(objStream);
string sLine = "";
int i = 0;
while (sLine != null)
{
    i++;
    sLine = objReader.ReadLine();
    if (sLine != null)
        Response.Output.WriteLine(sLine);
}
Context.Response.StatusCode = 404;
Context.Response.Status = "404 not found";
</pre>
<p>The other way to do it is by creating a new layout with all the controls and HTML structure in the layout. Don't rely on Sitecore's dynamic rendering binding and set the Sitecore.Context.Item on page load.</p>
<p>That code looks like this:</p>
<pre class="brush:csharp smart-tabs:true">
Server.Transfer("/layouts/404.aspx", true);
</pre>
<p>The preserveForm bool parameter is optional.<br />
The only problem with this - at least for my instance - is Session state is lost. Hunting for a Solution.</p>
<p>UPDATE*** Before I was even able to publish this post, I've found <a title="Preserve Session State when using Server.Transfer in Sitecore" href="http://www.victorfeinman.com/2011/05/preserve-session-state-when-using-server-transfer-in-sitecore/">a solution to the Session State issue</a> above and found a way to <a title="Server Side Redirect to a Sitecore Item" href="http://www.victorfeinman.com/2011/05/server-side-redirect-to-a-sitecore-item/">force a page through sitecore's httpRequestBegin pipeline</a> (actually a little slower than I thought...).</p>
<span class="akst_link"><a href="http://www.victorfeinman.com/?p=150&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_150">Share This</a>
</span><div class='diggWrap'><script type='text/javascript'>
<!--
digg_url='http://www.victorfeinman.com/2011/05/server-transfer-in-sitecore/';
digg_skin = 'compact';
digg_bgcolor = '#ffffff';
digg_title = 'Server.Transfer in Sitecore';
digg_bodytext = '';
digg_topic = '';
//-->
</script>
<script type='text/javascript' src='http://digg.com/tools/diggthis.js'></script>
</div>
<div class='share'><span class="akst_link"><a href="http://www.victorfeinman.com/?p=150&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_150">Share This</a>
</span></div>
<br class='clear' />]]></content:encoded>
			<wfw:commentRss>http://www.victorfeinman.com/2011/05/server-transfer-in-sitecore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preserve Session State when using Server.Transfer in Sitecore</title>
		<link>http://www.victorfeinman.com/2011/05/preserve-session-state-when-using-server-transfer-in-sitecore/</link>
		<comments>http://www.victorfeinman.com/2011/05/preserve-session-state-when-using-server-transfer-in-sitecore/#comments</comments>
		<pubDate>Fri, 06 May 2011 13:16:33 +0000</pubDate>
		<dc:creator>Some Guy</dc:creator>
				<category><![CDATA[Sitecore]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[httpRequestBegin]]></category>
		<category><![CDATA[Pipelines]]></category>
		<category><![CDATA[Session State]]></category>

		<guid isPermaLink="false">http://www.victorfeinman.com/?p=159</guid>
		<description><![CDATA[The title of this post is a little misleading, the solution doesn't use Server.Transfer, it provides an alternate solution involving the Sitecore.Web.WebUtil.RewriteUrl() method which relies on HttpContext.RewritePath() method. This solution may not fit the purpose for everyone or every purpose, but here goes: This - as far as I can tell - needs to be [...]]]></description>
			<content:encoded><![CDATA[<p>The title of this post is a little misleading, the solution doesn't use Server.Transfer, it provides an alternate solution involving the Sitecore.Web.WebUtil.RewriteUrl() method which relies on HttpContext.RewritePath() method.</p>
<p>This solution may not fit the purpose for everyone or every purpose, but here goes:</p>
<p>This - as far as I can tell - needs to be in the httpRequestBegin pipeline before the page starts rendering. For my purpose, I was trying to use the Sitecore setting RequestErrors.UseServerSideRedirect=true so the url of the requested item doesn't change on a 404 error (ItemNotFound). I needed to override the PerformRedirect method in Sitecore.Pipelines.HttpRequest.ExecuteRequest class. To do so I created a new class that would be replacing this one in the httpRequestBegin pipeline. However, you don't need to replace the Sitecore.Pipelines.HttpRequest.ExecuteRequest class, you can create your own process and add it to the end of the httpRequestBegin pipeline.</p>
<pre class="brush:csharp">    public class ExecuteRequest : Sitecore.Pipelines.HttpRequest.ExecuteRequest
    {
        protected override void PerformRedirect(string url)
        {
            if (Settings.RequestErrors.UseServerSideRedirect)
            {
                Sitecore.Web.WebUtil.RewriteUrl(url);
            }
            else
            {
                WebUtil.Redirect(url, false);
            }
        }
    }
</pre>
<p>Note that this will only work if the URL is to an .aspx page and in the page load method set the Sitecore.Context.Item to whichever item you'd like. This solution will not work for Sitecore Items.</p>
<p>If you'd like to server side redirect to a Sitecore Item, please find out how to do that <a title="Server Side Redirect to a Sitecore Item" href="http://www.victorfeinman.com/2011/05/server-side-redirect-to-a-sitecore-item/">here</a>.</p>
<p>Now you have to replace the  in the web.config, you can do it by modifying the web.config directly OR if you're like me and would like to keep the web.config file as close to the release version as possible, then you can add a .config file to the /App_Config/Include folder with something similar to the below XML.</p>
<pre class="brush:xml">          your.namespace.ExecuteRequest, yourAssembly
</pre>
<p>Now the page you previously tried to Server.Transfer to that didn't have state, now has session state!</p>
<span class="akst_link"><a href="http://www.victorfeinman.com/?p=159&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_159">Share This</a>
</span><div class='diggWrap'><script type='text/javascript'>
<!--
digg_url='http://www.victorfeinman.com/2011/05/preserve-session-state-when-using-server-transfer-in-sitecore/';
digg_skin = 'compact';
digg_bgcolor = '#ffffff';
digg_title = 'Preserve Session State when using Server.Transfer in Sitecore';
digg_bodytext = '';
digg_topic = '';
//-->
</script>
<script type='text/javascript' src='http://digg.com/tools/diggthis.js'></script>
</div>
<div class='share'><span class="akst_link"><a href="http://www.victorfeinman.com/?p=159&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_159">Share This</a>
</span></div>
<br class='clear' />]]></content:encoded>
			<wfw:commentRss>http://www.victorfeinman.com/2011/05/preserve-session-state-when-using-server-transfer-in-sitecore/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

