<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Using jqGrid with ASP.NET MVC: Understanding LINQ Errors</title>
	<atom:link href="http://blogs.teamb.com/craigstuntz/2009/05/05/38274/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.teamb.com/craigstuntz/2009/05/05/38274/</link>
	<description>C# • Entity Framework • Functional Programming • MVC • Web</description>
	<pubDate>Sun, 12 Feb 2012 04:35:37 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: Using jqGrid with ASP.NET MVC &#124; Tuấn&#39;s blog</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/05/05/38274/#comment-31881</link>
		<dc:creator>Using jqGrid with ASP.NET MVC &#124; Tuấn&#39;s blog</dc:creator>
		<pubDate>Thu, 21 Jul 2011 09:45:18 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38274#comment-31881</guid>
		<description>[...] Using jqGrid with ASP.NET MVC: Introduction Using jqGrid with ASP.NET MVC: LINQ Extensions  Using jqGrid with ASP.NET MVC: Finally, A Solution  Using jqGrid with ASP.NET MVC: Search and Formatting  Using jqGrid with ASP.NET MVC: Deleting Records  Using jqGrid with ASP.NET MVC: Understanding LINQ Errors [...]</description>
		<content:encoded><![CDATA[<p>[...] Using jqGrid with ASP.NET MVC: Introduction Using jqGrid with ASP.NET MVC: LINQ Extensions  Using jqGrid with ASP.NET MVC: Finally, A Solution  Using jqGrid with ASP.NET MVC: Search and Formatting  Using jqGrid with ASP.NET MVC: Deleting Records  Using jqGrid with ASP.NET MVC: Understanding LINQ Errors [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Stuntz</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/05/05/38274/#comment-10280</link>
		<dc:creator>Craig Stuntz</dc:creator>
		<pubDate>Mon, 19 Oct 2009 09:39:52 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38274#comment-10280</guid>
		<description>Tony, I discussed this change to MVC in &lt;a href="http://blogs.teamb.com/craigstuntz/2009/10/05/38476/" rel="nofollow"&gt;this post&lt;/a&gt;. In the specific case of jqGrid, it is safe to use a GET request, because the data returned is not an array. See the post I linked for instructions on how to tell MVC to allow the GET.</description>
		<content:encoded><![CDATA[<p>Tony, I discussed this change to MVC in <a href="http://blogs.teamb.com/craigstuntz/2009/10/05/38476/" rel="nofollow">this post</a>. In the specific case of jqGrid, it is safe to use a GET request, because the data returned is not an array. See the post I linked for instructions on how to tell MVC to allow the GET.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/05/05/38274/#comment-10270</link>
		<dc:creator>Tony</dc:creator>
		<pubDate>Mon, 19 Oct 2009 00:47:39 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38274#comment-10270</guid>
		<description>And, armed with that data, it's easier to find the cause.  Turns out this is a known, breaking change by the MVC team in 2.0 P2 - which I am using.

ASP.NET MVC Preview 2 Changes to Prevent JSON Hijacking
Phil Haack recently blogged about a very subtle JSON vulnerability and a related JSON Hijacking problem that can hijack sensitive data returned by a JSON GET. He outlines the problem very well and in concrete detail - and even supplies a sample project you can use to see the vulnerabilities in action yourself. So I won't detail the issue here, other than to say that he raises a very serious specter, which is that GETs for JSON data can be prone to a very subtle, yet vicious, security vulnerability.

Given Phil's role in defining the direction of ASP.NET MVC, it's therefore not surprising to see that Preview2 of ASP.NET MVC 2 (up on codeplex.com) introduces a breaking change to address this. Specifically, as the release notes outline, an ASP.NET MVC JsonResult will now only respond to HttpPost requests.

http://www.devproconnections.com/tabId/180/itemId/4587/Security-Changes-in-ASPNET-MVC-V2-Good-News-for.aspx

http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx

Now I just have to figure out how to get all these GET examples converted to working POST examples.  :-)</description>
		<content:encoded><![CDATA[<p>And, armed with that data, it&#8217;s easier to find the cause.  Turns out this is a known, breaking change by the MVC team in 2.0 P2 - which I am using.</p>
<p>ASP.NET MVC Preview 2 Changes to Prevent JSON Hijacking<br />
Phil Haack recently blogged about a very subtle JSON vulnerability and a related JSON Hijacking problem that can hijack sensitive data returned by a JSON GET. He outlines the problem very well and in concrete detail - and even supplies a sample project you can use to see the vulnerabilities in action yourself. So I won&#8217;t detail the issue here, other than to say that he raises a very serious specter, which is that GETs for JSON data can be prone to a very subtle, yet vicious, security vulnerability.</p>
<p>Given Phil&#8217;s role in defining the direction of ASP.NET MVC, it&#8217;s therefore not surprising to see that Preview2 of ASP.NET MVC 2 (up on codeplex.com) introduces a breaking change to address this. Specifically, as the release notes outline, an ASP.NET MVC JsonResult will now only respond to HttpPost requests.</p>
<p><a href="http://www.devproconnections.com/tabId/180/itemId/4587/Security-Changes-in-ASPNET-MVC-V2-Good-News-for.aspx" rel="nofollow">http://www.devproconnections.com/tabId/180/itemId/4587/Security-Changes-in-ASPNET-MVC-V2-Good-News-for.aspx</a></p>
<p><a href="http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx" rel="nofollow">http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx</a></p>
<p>Now I just have to figure out how to get all these GET examples converted to working POST examples.  <img src='http://blogs.teamb.com/craigstuntz/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/05/05/38274/#comment-10269</link>
		<dc:creator>Tony</dc:creator>
		<pubDate>Mon, 19 Oct 2009 00:09:01 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38274#comment-10269</guid>
		<description>Ah, I love Fiddler.  Turns out that the objection here is that the example is using a GET and MVC (or is it ASP.NET?) blocks that by default as a cross-site security risk.  Now I just have to figure out how to get the jqGrid to send it's parameters as a POST.  :-)</description>
		<content:encoded><![CDATA[<p>Ah, I love Fiddler.  Turns out that the objection here is that the example is using a GET and MVC (or is it ASP.NET?) blocks that by default as a cross-site security risk.  Now I just have to figure out how to get the jqGrid to send it&#8217;s parameters as a POST.  <img src='http://blogs.teamb.com/craigstuntz/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/05/05/38274/#comment-10266</link>
		<dc:creator>Tony</dc:creator>
		<pubDate>Sun, 18 Oct 2009 20:47:35 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38274#comment-10266</guid>
		<description>This has been a *great*series of articles and just what I needed to get some "real" (read: not HTML) grids into my MVC applications.

I have a question about a problem I am having with a simple Entity Framework implementation I am doing with MVC 2.0 P2.  I think/hope this is something simple, and I don't think (though I could be wrong) that this is related to the issues you describe above.

I have a simple controller action that does the following:

public ActionResult GridDemoData(int page, int rows, string search, string sidx, string sord)
{/*
    var repository = new Repository();
    var model = from entity in repository.SelectAll().OrderBy(sidx + " " + sord)
                select new
                {
                    IntProperty = entity.IntProperty,
                    StringProperty = entity.StringProperty,
                    DateProperty = entity.DateProperty.ToString(System.Globalization.CultureInfo.CurrentUICulture)
                };
    */
    var dc = new InvestorEntities();
    var model = dc.Investor
                  //.Include("Organization")
                  //.Include("LastModifiedUser")
                    .Where(i =&#62; !i.IsDeleted);

     JsonResult r = Json(model.ToJqGridData(page, rows, sidx + " " + sord, search,
                new[] { "InvestorID", "IsDeleted" }));

      return r;
}

And here is my complete jqGrid definition:


    
        $(function() {
            $('#investorGrid').jqGrid({
                url: '',
                imgpath: '',
                datatype: 'json',
                height: 'auto',
                jsonReader: {
                    root: 'Rows',
                    page: 'Page',
                    total: 'Total',
                    records: 'Records',
                    repeatitems: false,
                    userdata: 'UserData',
                    id: 'InvestorID'
                },
                loadui: 'block',
                mtype: 'GET',
                multiboxonly: true,
                rowNum: 5,
                rowList: [5, 10, 15, 20],
                viewrecords: true,
                multiselect: false,
                caption: 'Investors',
                colNames: ['Investor ID', 'Is Deleted'],
                colModel: [
                    { name: 'InvestorID', index: 'InvestorID' },
                    { name: 'IsDeleted', index: 'IsDeleted' } 
                ],
                pager: $('#investorPager'),
                sortname: 'InvestorID',
                sortorder: 'asc'
            }).navGrid('#investorPager', { edit: false, add: false, del: false, search: false });
            $('#investorSearch').filterGrid('#' + grid.attr('InvestorID'), {
                gridModel: false,
                filterModel: [{
                    label: 'Search',
                    name: 'search',
                    stype: 'text'
                }]
            });
        });
   
   
    
    
    

The problem I run into here is that my data gets blocked/lost somewhere between "return r" - at which point I have a filled object hierarchy - and showing up on the screen.  I don't get any error - I just get no rows.

For a while, I thought that perhaps the default JsonRequest.JsonRequestBehavior of "DenyGet" was getting me, but explicitly setting this to "AllowGet" right before "return r" in my action doesn't change anything.

I tried swapping out my datatype of json for local and using a javascript array and it worked fine, so I think my jqGrid definition is good.  I am just at my wit's end here and I am hoping you have seen this before.

Thanks in advance for your time and once again - great articles!

Tony</description>
		<content:encoded><![CDATA[<p>This has been a *great*series of articles and just what I needed to get some "real" (read: not HTML) grids into my MVC applications.</p>
<p>I have a question about a problem I am having with a simple Entity Framework implementation I am doing with MVC 2.0 P2.  I think/hope this is something simple, and I don&#8217;t think (though I could be wrong) that this is related to the issues you describe above.</p>
<p>I have a simple controller action that does the following:</p>
<p>public ActionResult GridDemoData(int page, int rows, string search, string sidx, string sord)<br />
{/*<br />
    var repository = new Repository();<br />
    var model = from entity in repository.SelectAll().OrderBy(sidx + " " + sord)<br />
                select new<br />
                {<br />
                    IntProperty = entity.IntProperty,<br />
                    StringProperty = entity.StringProperty,<br />
                    DateProperty = entity.DateProperty.ToString(System.Globalization.CultureInfo.CurrentUICulture)<br />
                };<br />
    */<br />
    var dc = new InvestorEntities();<br />
    var model = dc.Investor<br />
                  //.Include("Organization")<br />
                  //.Include("LastModifiedUser")<br />
                    .Where(i =&gt; !i.IsDeleted);</p>
<p>     JsonResult r = Json(model.ToJqGridData(page, rows, sidx + " " + sord, search,<br />
                new[] { "InvestorID", "IsDeleted" }));</p>
<p>      return r;<br />
}</p>
<p>And here is my complete jqGrid definition:</p>
<p>        $(function() {<br />
            $(&#8217;#investorGrid&#8217;).jqGrid({<br />
                url: &#8221;,<br />
                imgpath: &#8221;,<br />
                datatype: &#8216;json&#8217;,<br />
                height: &#8216;auto&#8217;,<br />
                jsonReader: {<br />
                    root: &#8216;Rows&#8217;,<br />
                    page: &#8216;Page&#8217;,<br />
                    total: &#8216;Total&#8217;,<br />
                    records: &#8216;Records&#8217;,<br />
                    repeatitems: false,<br />
                    userdata: &#8216;UserData&#8217;,<br />
                    id: &#8216;InvestorID&#8217;<br />
                },<br />
                loadui: &#8216;block&#8217;,<br />
                mtype: &#8216;GET&#8217;,<br />
                multiboxonly: true,<br />
                rowNum: 5,<br />
                rowList: [5, 10, 15, 20],<br />
                viewrecords: true,<br />
                multiselect: false,<br />
                caption: &#8216;Investors&#8217;,<br />
                colNames: ['Investor ID', 'Is Deleted'],<br />
                colModel: [<br />
                    { name: 'InvestorID', index: 'InvestorID' },<br />
                    { name: 'IsDeleted', index: 'IsDeleted' }<br />
                ],<br />
                pager: $(&#8217;#investorPager&#8217;),<br />
                sortname: &#8216;InvestorID&#8217;,<br />
                sortorder: &#8216;asc&#8217;<br />
            }).navGrid(&#8217;#investorPager&#8217;, { edit: false, add: false, del: false, search: false });<br />
            $(&#8217;#investorSearch&#8217;).filterGrid(&#8217;#&#8217; + grid.attr(&#8217;InvestorID&#8217;), {<br />
                gridModel: false,<br />
                filterModel: [{<br />
                    label: 'Search',<br />
                    name: 'search',<br />
                    stype: 'text'<br />
                }]<br />
            });<br />
        });</p>
<p>The problem I run into here is that my data gets blocked/lost somewhere between "return r" - at which point I have a filled object hierarchy - and showing up on the screen.  I don&#8217;t get any error - I just get no rows.</p>
<p>For a while, I thought that perhaps the default JsonRequest.JsonRequestBehavior of "DenyGet" was getting me, but explicitly setting this to "AllowGet" right before "return r" in my action doesn&#8217;t change anything.</p>
<p>I tried swapping out my datatype of json for local and using a javascript array and it worked fine, so I think my jqGrid definition is good.  I am just at my wit&#8217;s end here and I am hoping you have seen this before.</p>
<p>Thanks in advance for your time and once again - great articles!</p>
<p>Tony</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Tryand</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/05/05/38274/#comment-9983</link>
		<dc:creator>James Tryand</dc:creator>
		<pubDate>Mon, 05 Oct 2009 19:49:33 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38274#comment-9983</guid>
		<description>You might want to look at the good work jason dentler has done for making sqlite a good provider for an in memory database for unit testing.</description>
		<content:encoded><![CDATA[<p>You might want to look at the good work jason dentler has done for making sqlite a good provider for an in memory database for unit testing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig Stuntz</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/05/05/38274/#comment-8248</link>
		<dc:creator>Craig Stuntz</dc:creator>
		<pubDate>Tue, 30 Jun 2009 17:21:04 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38274#comment-8248</guid>
		<description>I'll do more when I get time.</description>
		<content:encoded><![CDATA[<p>I&#8217;ll do more when I get time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hoang</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/05/05/38274/#comment-8246</link>
		<dc:creator>Hoang</dc:creator>
		<pubDate>Tue, 30 Jun 2009 17:20:06 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38274#comment-8246</guid>
		<description>Thank you for the tutorials that you have posted so far. They are very helpful. Are you still planning on continuing with the series or have you decided to stop? Thanks.</description>
		<content:encoded><![CDATA[<p>Thank you for the tutorials that you have posted so far. They are very helpful. Are you still planning on continuing with the series or have you decided to stop? Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dantor</title>
		<link>http://blogs.teamb.com/craigstuntz/2009/05/05/38274/#comment-6742</link>
		<dc:creator>Dantor</dc:creator>
		<pubDate>Sun, 17 May 2009 06:20:04 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.teamb.com/craigstuntz/?p=38274#comment-6742</guid>
		<description>First of all i would like to thank you for your tutorial. It really helped me to get started using jqGrid with ASP.NET MVC.. I would like to see more scenarios using jqGrid and one of them that i couldn't figure out is using subgrid.. it will be of real help to see a tutorial on this.. 
thanks</description>
		<content:encoded><![CDATA[<p>First of all i would like to thank you for your tutorial. It really helped me to get started using jqGrid with ASP.NET MVC.. I would like to see more scenarios using jqGrid and one of them that i couldn&#8217;t figure out is using subgrid.. it will be of real help to see a tutorial on this..<br />
thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>

