<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ASP.NET MVC Tip #15 – Pass Browser Cookies and Server Variables as Action Parameters</title><link>http://weblogs.asp.net/stephenwalther/archive/2008/07/08/asp-net-mvc-tip-15-pass-browser-cookies-and-server-variables-as-action-parameters.aspx</link><description>In this tip, I demonstrate how you can pass browser cookies and HTTP server variables to controller action methods in the same way as you can pass form and query string parameters. Imagine that you make the following browser request against an ASP.NET</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>MVC Controller Action Security Hole &amp;laquo;  SquaredRoot</title><link>http://weblogs.asp.net/stephenwalther/archive/2008/07/08/asp-net-mvc-tip-15-pass-browser-cookies-and-server-variables-as-action-parameters.aspx#7113973</link><pubDate>Tue, 09 Jun 2009 02:29:03 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7113973</guid><dc:creator>MVC Controller Action Security Hole «  SquaredRoot</dc:creator><author>MVC Controller Action Security Hole «  SquaredRoot</author><description>&lt;p&gt;Pingback from &amp;nbsp;MVC Controller Action Security Hole &amp;amp;laquo; &amp;nbsp;SquaredRoot&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7113973" width="1" height="1"&gt;</description></item><item><title>re: ASP.NET MVC Tip #15 – Pass Browser Cookies and Server Variables as Action Parameters</title><link>http://weblogs.asp.net/stephenwalther/archive/2008/07/08/asp-net-mvc-tip-15-pass-browser-cookies-and-server-variables-as-action-parameters.aspx#6435869</link><pubDate>Wed, 23 Jul 2008 15:27:15 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6435869</guid><dc:creator>VB</dc:creator><author>VB</author><description>&lt;p&gt;Hi Stephen,&lt;/p&gt;
&lt;p&gt;I am new to MVC and was wondering when you pass action parameters Is there any way NOT TO DISPLAY them in the url?&lt;/p&gt;
&lt;p&gt;for eg: &lt;a rel="nofollow" target="_new" href="&lt;a rel="nofollow" target="_new" href="http://localhost/mvcapp/blogs/"&gt;http://localhost/mvcapp/blogs/&lt;/a&gt;24"&gt;localhost/.../24&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;can we display this as&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://localhost/mvcapp/blogs/"&gt;http://localhost/mvcapp/blogs/&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;or maybe some other way where we do not display the parameter to the user?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6435869" width="1" height="1"&gt;</description></item><item><title>re: ASP.NET MVC Tip #15 – Pass Browser Cookies and Server Variables as Action Parameters</title><link>http://weblogs.asp.net/stephenwalther/archive/2008/07/08/asp-net-mvc-tip-15-pass-browser-cookies-and-server-variables-as-action-parameters.aspx#6385454</link><pubDate>Thu, 10 Jul 2008 20:01:19 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6385454</guid><dc:creator>Dylan Beattie</dc:creator><author>Dylan Beattie</author><description>&lt;p&gt;Exactly as tf124 said... how do you combine these techniques with something like Html.BuildUrlFromExpression() or Html.ActionLink&amp;lt;T&amp;gt;() ?&lt;/p&gt;
&lt;p&gt;These methods won't compile unless you specify their arguments in the method call - so how can you refer to them within pages and still use the automatic parameter population features?&lt;/p&gt;
&lt;p&gt;Great article, though - thanks!&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6385454" width="1" height="1"&gt;</description></item><item><title>links for 2008-07-10 &amp;laquo; Praveen&amp;#8217;s Blog</title><link>http://weblogs.asp.net/stephenwalther/archive/2008/07/08/asp-net-mvc-tip-15-pass-browser-cookies-and-server-variables-as-action-parameters.aspx#6383381</link><pubDate>Thu, 10 Jul 2008 10:48:59 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6383381</guid><dc:creator>links for 2008-07-10 « Praveen’s Blog</dc:creator><author>links for 2008-07-10 « Praveen’s Blog</author><description>&lt;p&gt;Pingback from &amp;nbsp;links for 2008-07-10 &amp;amp;laquo; Praveen&amp;amp;#8217;s Blog&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6383381" width="1" height="1"&gt;</description></item><item><title>re: ASP.NET MVC Tip #15 – Pass Browser Cookies and Server Variables as Action Parameters</title><link>http://weblogs.asp.net/stephenwalther/archive/2008/07/08/asp-net-mvc-tip-15-pass-browser-cookies-and-server-variables-as-action-parameters.aspx#6380481</link><pubDate>Wed, 09 Jul 2008 16:34:52 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6380481</guid><dc:creator>tf124</dc:creator><author>tf124</author><description>&lt;p&gt;So... how could I link to a controller that accepts server variables via an Html.ActionLink. &amp;nbsp;It would get a compile error if you don't specify all the parameters... yet that would be exactly what I want to do... not specify the parameters and have them filled in for me.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6380481" width="1" height="1"&gt;</description></item><item><title>re: ASP.NET MVC Tip #15 – Pass Browser Cookies and Server Variables as Action Parameters</title><link>http://weblogs.asp.net/stephenwalther/archive/2008/07/08/asp-net-mvc-tip-15-pass-browser-cookies-and-server-variables-as-action-parameters.aspx#6379229</link><pubDate>Wed, 09 Jul 2008 06:29:24 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6379229</guid><dc:creator>Haacked</dc:creator><author>Haacked</author><description>&lt;p&gt;I wrote a blog post that addresses the fundamental security issue in this case, which is not passing server vars into an action method. &lt;a rel="nofollow" target="_new" href="http://haacked.com/archive/2008/07/08/user-input-in-sheep-clothing.aspx"&gt;haacked.com/.../user-input-in-sheep-clothing.aspx&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6379229" width="1" height="1"&gt;</description></item><item><title>User Input In Sheep</title><link>http://weblogs.asp.net/stephenwalther/archive/2008/07/08/asp-net-mvc-tip-15-pass-browser-cookies-and-server-variables-as-action-parameters.aspx#6379226</link><pubDate>Wed, 09 Jul 2008 06:27:56 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6379226</guid><dc:creator>you've been HAACKED</dc:creator><author>you've been HAACKED</author><description>&lt;p&gt;User Input In Sheep&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6379226" width="1" height="1"&gt;</description></item><item><title>MVC Controller Action Security Hole</title><link>http://weblogs.asp.net/stephenwalther/archive/2008/07/08/asp-net-mvc-tip-15-pass-browser-cookies-and-server-variables-as-action-parameters.aspx#6378485</link><pubDate>Wed, 09 Jul 2008 02:00:44 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6378485</guid><dc:creator>Troy Goode: SquaredRoot</dc:creator><author>Troy Goode: SquaredRoot</author><description>&lt;p&gt;MVC Controller Action Security Hole&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6378485" width="1" height="1"&gt;</description></item><item><title>re: ASP.NET MVC Tip #15 – Pass Browser Cookies and Server Variables as Action Parameters</title><link>http://weblogs.asp.net/stephenwalther/archive/2008/07/08/asp-net-mvc-tip-15-pass-browser-cookies-and-server-variables-as-action-parameters.aspx#6377886</link><pubDate>Tue, 08 Jul 2008 22:22:19 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6377886</guid><dc:creator>Troy Goode</dc:creator><author>Troy Goode</author><description>&lt;p&gt;Thanks for the tip Stephen, specifically about passing cookies in.&lt;/p&gt;
&lt;p&gt;Unfortunately I think Francois is 100% on point regarding the security implications of passing server variables this way. I've examined some potential pitfalls on my blog:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.squaredroot.com/post/2008/07/08/MVC-Routing-Security-Hole.aspx"&gt;www.squaredroot.com/.../MVC-Routing-Security-Hole.aspx&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6377886" width="1" height="1"&gt;</description></item><item><title>MVC Routing Security Hole</title><link>http://weblogs.asp.net/stephenwalther/archive/2008/07/08/asp-net-mvc-tip-15-pass-browser-cookies-and-server-variables-as-action-parameters.aspx#6377854</link><pubDate>Tue, 08 Jul 2008 22:14:56 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6377854</guid><dc:creator>Troy Goode: SquaredRoot</dc:creator><author>Troy Goode: SquaredRoot</author><description>&lt;p&gt;MVC Routing Security Hole&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6377854" width="1" height="1"&gt;</description></item></channel></rss>