December 2008

You are browsing the site archives by month.

Problems with Dean’s Permalinks Migration after WordPress 2.7

I updated to WordPress 2.7 when it was released and on the surface everything seemed to work just fine. Then today when i clicked a old link to one of my wordpress sites i got a 404 message.

It turns out that Dean’s Permalinks Migration plugin stopped working after WordPress 2.7 (i assume at least, i didn’t do any research about it). You use Dean’s Permalinks Migration plugin to do a 301 (SEO friendly) redirect from your old permalink structure to a new one.

I used /year/month/day/post-title before but i wanted to change to just /post-title and Dean’s Permalinks Migration plugin worked great. But as i said before it stopped worked after we installed WordPress 2.7.

The solution i found was to install another plugin called Redirection that is used to do all sort of redirects in WordPress. After i installed the plugin i just added a regular expression redirect like this.

301-redirect

This means something like redirect any url that looks like /digits/digits/digits/text to /text. The $4 means to grab the text from the last * in the source URL.

Publicerat av den

ASP.NET membership: System.Web.Security. SqlRoleProvider problems

I had this really weird problem just now. I have done some work with the ASP.NET Membership provider and everything has been working great. But when i tried to deploy my application to the server i got this:

The ‘System.Web.Security.SqlRoleProvider’ requires a database schema compatible with schema version ’1′. However, the current database schema is not compatible with this version. You may need to either install a compatible schema with aspnet_reqsql.exe (available in the framework installation directory), or upgrade the provider to a newer version.

Alright, my database was exactly the same and everything looked fine. I tried to recreate my database with the aspnet_regsql.exe tool but nothing worked. Then i finally found this thread on the MSDN messageboard and one guy said that he gave his application a name in the aspnet_Applications table and put that name in the web.config like this.

And that solved it. Really really strange and i have no idea if this is a bug or whatever. On my local machine (Vista with IIS7) it worked great to have a application named “/” but on my production machin (a Server 2003 with IIS6) it did not.

Now i should stop working for today.

Publicerat av den

Cascade delete in Entity Framework

I hade a really hard time getting a simple cascade delete to work with the Entity Framework and i thought i had to write it down here so that i can remember it in the future.

I was trying to delete a item from my database with some childrens. But i got the error

A relationship is being added or deleted from an AssociationSet ‘FK_ItemChildren_Item’. With cardinality constraints, a corresponding ‘ItemChildren’ must also be added or deleted.

I started to google on it and i found this thread in the MSDN forums. The first suggestion where to add cascade delete to the database and then update the model to get the changes. I did that but i still got the same error. The problem where this.

The SSDL part of the edmx file where updated correctly.

But the CSDL part where not updated:

The line in “<OnDelete Action=”Cascade”></OnDelete>” where not updated for some reason. When i added that in the model it worked. I guess the designer is not 100% even though the released EF.

UPDATE!

Alexander Muylaert sent me this script via the comments.

Thanks for your blog.  I had this issue on a huge model.  Over 180 tables and hundreds of references.  I didn’t feel like checking all this manually.

I open the edmx file as an xmldocument and executed the following code.  It fixes this issue in batch…  The code is not cleaned, but I have already lost a complete day and I can’t afford to waste more time.  I would like to post this, so someone could use this code and post a cleaned version.

Publicerat av den

Generate expiring urls for Amazon S3 via a WordPress Plugin

I am a .net developer and haven’t done any PHP work ever. But i use WordPress and for some time now i been looking for a plugin that could generate a URL for Amazon S3 that is “signed” and will expire after a certain amount of time.

I posted the question on both wordpress and amazon forums but haven’t got any replies. Well .. maybe i did not explain my problem good or nobody else is interested in this.

So i figured i had to take care of this myself. And as i said. I’m a total newbie in both PHP and WordPress plugins so my plugin is probably really really stupid and i would be happy if somebody could send suggestions how to make it better. But it works.

How does it work?

You just add

[S3 bucket=yourbucket text=your link text]the_object_name.txt[/S3]

to your post or page and it will generate a expiring urls that no leecher can link to. If you don’t supply and link text it will not generate a link and just print the URL. I use the same bucket names as URL’s (like netplay.whoa.nu) and if you use Amazon standard urls you must change this.

Download: Amazon S3 URL Generator

Thanks to this guy for the PHP script i based this on.

Publicerat av den

StackoverflowException with ASP.NET MVC

I got this strange Stackoverflow exeption today in my MVC project. I have made some modifications to my data model and all of a sudden i got a stackoverflowexception when i was submitting data via a form.

I started googling about it and found this thread on the asp.net message board. It turns out that the Default modelbinder was causing this. The modelbinder is basically what makes ASP.NET MVC able to automatically bind form post values to your object. You probably know it in some degree if you reading this.

Anyway, to solve the problem you should declare what fields you want to include in the binding by adding an attribute like this. This way the modelbinder wont have to deal with the properties that you do not handle in some way.

According to the post in the forums this is a bug that will be fixed in the next release of the MVC framework. Now back to work!

Read more about both model binders and the bind attribute at Scott Guthries blog post about the beta.

Publicerat av den