ASP.NET MVC conditionally render a partial view

by Cliff 15. March 2010

I was looking for a clean way to conditionally show a block of html and came across this post

It oulines a really clean way to conditionally render a partial view while avoiding having if/else logic directly in your view.

 

SQL Server 2008 slow query on fulltext indexed column

by Cliff 27. January 2010

Experienced a very strang issue with a query after upgrading to SQL Server 2008 from 2005.  A query that took less than one second on SQL 2005 ended up taking 27 seconds on SQL Server 2008. 

Exact scenario:

Query that selects data and one of the columns in the select list belonged to a full text index.  If this column is not in the select list, the query runs in under one second.
Removing the full text index did not make a difference
Changing the data type from nvarchar(max) to nvarchar(3000) did not make a difference
adding a where filter of column != '' worked

Not sure why this happened and only in SQL 2008 but not in 2005 but if you are seeing the same issue, I hope this article helps.

LINQ to SQL dynamically set order by

by Cliff 16. January 2010

Often I find the need to dynamically specify the order by for a LINQ to SQL query.  I came across a very nice example of this here

I needed to use this technique with a CSLA class, so I needed to call it in a sligthly different manner than the way explained in the article.  I was grouping information and needed to then dynamically set the order by and finally place the results into a CSLA read only list.

I accomplished this as follows:

  1. First I specified my LINQ query and selected the results into an annonymous type and placed into a variable (var data = ...)

  2. Next, called my OrderBy extension method on the LINQ query created in #1

    var ordered = data.OrderBy(criteria.OrderByProperty, criteria.OrderByDesc);


    The criteria object is the typical pattern used in CSLA to pass data to your data access methods such as fetch.

  3. Finally, I selected the data elements into my CSLA list item, and add to the parent list object

    var selected = ordered.Select(a => MyCslaListItem.GetMyCslaListItem(a.Id, a.Name, a.Email, ...));
    this.AddRange(selected);

I understand I could do this in fewer steps, but am leaving as it to explicitly outline the approach taken.

 

 

How to learn the Google Go Programming Language

by Cliff 14. January 2010

In an effort to learn the google go programming lanuage, I am keeping track of useful links on the go language.

http://www.youtube.com/watch?v=rKnDgT73v8s&feature=player_embedded - Google Tech Talk on Go

http://golang.org/doc/go_talk-20091030.pdf - PDF for tech talk

 

Tags: go

Go | Google

Generating a valid RSS feed using SyndicationFeed and Rss20FeedFormatter

by Cliff 12. January 2010

If you are using the .NET Rss20FeedFormatter and SyndicationFeed classes to generate an RSS feed, you may run into an issue of needing to include a link attribute to the channel element.  If you validate the default RSS generated the validation will fail since the channel element does not contain a link attribute.

You can test this by going to http://beta.feedvalidator.org and entering your feed Url.  If you recieve the error

Missing channel element: link

you can modify your code as follows:

 

SyndicationFeed syndicationFeed = new SyndicationFeed(synicationItems);
syndicationFeed.AttributeExtensions.Add(new XmlQualifiedName("link"), "http://yoursite.com");

 

This will produce a valid RSS feed with a channel that contains a link attribute.

.Net | RSS

ASP.NET MVC strongly typed view error Could not load type

by Cliff 5. December 2009

I have been doing some work on a asp.net webforms website that has been "upgraded" to also include the mvc bits.  One issue I ran into was an error when trying to create a strongly typed view.  I was receiving the below exception:

Parser Error Message: Could not load type 'System.Web.Mvc.ViewPage<MyViewModel>'.

I also was not getting intellisense in my View page when trying to access the Model property.

It sounds like this relates to dll references, and I found the solution at the below link.  

What I did to resolve was to create a new MVC project and then copy the web.config from the Views directory to my older webforms website.  That did the trick...

http://forums.asp.net/p/1378448/2908692.aspx

Error when stopping Tomcat 6 on Ubuntu 9.10

by Cliff 28. November 2009

I recently installed Tomcat 6 on Ubuntu 9.10 and when trying to stop the tomcat server, I was receiving an error.

I was issuing the statement

sudo ./shutdown.sh 

and received an error, including:

Catalina.stop: java.io.FileNotFoundException: /usr/share/tomcat6/conf/server.xml

To get around this, I used a different command to stop and start the server:

$ sudo service tomcat6 stop

$ sudo service tomcat6 start

Hope others find this useful.

asp.net mvc IIS 7 404 erro

by Cliff 7. October 2009

If you are having issue getting an asp.net MVC web site running on a server with IIS 7 you should check your web.config settings.  I tried a variety of things, searched around the net, and finally found what I was looking for.

After some trial and error, I found that in order for things to work in IIS7 you need the below entries in your web.config, in the system.Webserver section within modules and handlers (leave other items that may already be there). 

<modules runAllManagedModulesForAllRequests="true" >
                <remove name="UrlRoutingModule"/>
                <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            </modules>
            <handlers>
                <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
            </handlers>

 

I found the below articles to be very helpful in troubleshooting the issue I was having.

 

 http://chriscavanagh.wordpress.com/2008/03/11/aspnet-routing-goodbye-url-rewriting/

 

disqus update_thread HTTP method for this call must be POST

by Cliff 4. October 2009

Recently I was trying to work with the Disqus comment system's API (version 1.1) and when trying to update infomation via the API, I kepy receiving:

 HTTP method for this call must be POST

In order to no longer recieve the error, I modified the URL I was posting to to end with a "/", for example:

http://disqus.com/api/update_thread/

That fixed the issue...

 

 

SQL Server Protocol error in TDS stream Communication link failure TCP Provider: An existing connection was forcibly closed by the remote host

by Cliff 28. September 2009

Recently ran into an issue with long running sql queries that used TCP to communicate between different SQL Server servers.  We sporatically noticed the below errors and SQL job failures for jobs that ran long running sql queries.

Error: 2009-09-28 08:43:40.62     Code: 0xC0202009     Source:      Description: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Protocol error in TDS stream".  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Communication link failure".  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "TCP Provider: An existing connection was forcibly closed by the remote host.  ".  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Communication link failure".  An OLE DB record is ...  The package execution fa...  The step failed.

After some research, the below KB article outlines that TCP Chimney may be the cause.  Turns out, TCP Chimney may require an update the your NIC drivers.  

http://support.microsoft.com/kb/945977

We have not had the chance to upgrade our drivers, but we did disable TCP Chimney and that eliminated the error. To disable, issue the below statement at the command prompt (does not require a restart):

Netsh int ip set chimney DISABLED

Cliff Gray's Info

Cliff Gray
Developer/Founder GrayTechnology.com.

E-mail me Send mail

Authors

Calendar

<<  July 2010  >>
MoTuWeThFrSaSu
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar

Blogroll

Download BlogEngine.NET

Download at CodePlex

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Subscribe