A web part can't use certain objects such as Page.Request as detailed in Best Practice to create designer friendly server controls when running in a designer such as SharePoint Designer.
You can use the DesignMode property to determine if a web part is running inside a designer and act appropriately.
However this doesn't seem to work for Toolparts - it always returns false.
How do you determine if a Toolpart is running inside SharePoint Designer?