Luuuukke.NET

Bugs, headache, lost hairs... I love IT

Error: "Cannot use a leading .. to exit above the top directory..."

clock August 31, 2010 20:08 by author Luuuukke

I was getting this error on url rewrites for url containing multiples "/xxx/xxx" with url rewriter...

After being stuck with this error on a new app with multiple masterpages & rewriting,
I found this article and this one, about themes images not displayed when rewriting, but also about the "cannot.... bla bla"

"Rewriting pathes with slashes ("/") in it can lead to this f... erro "Cannot use a leading ..." error when running the website within IIS."

Bingo ! it works ! One hyperlink by one, i set the ImageUrl programmatically for my masterpages,
and the error disappeared when i eventually set the ImageUrl in code for a child user control i use in a masterpage...

So, set the hyperlink's ImageUrl property programmatically for masterpages & controls, That's all Cool

Note that i sometimes get this error from opnline app when browsed by crawlers;..
I tried evrything, ith browser caps and so on.. nothing worked.
Gonna give this a try too :-)

 



Minify css and jss files automatically with Visual Studio Web Deployment Projects

clock August 29, 2010 16:38 by author Luuuukke

After googling for some time, i finally found the perfect solution to minify css stylesheets and javascripts .js files.
I wanted to automaticaly compress releases files when building my websites, using web deployment projects...

The solution uses the Yahoo YUI Compressor, especially the compressor for .NET release,
(see the sample web deployment project solutions in the other downloads available !)

to put it into work, edit the web deployment project as following:

add a reference to the YUI Compressor on top of your project file:

<UsingTask TaskName="CompressorTask" AssemblyFile="..\{path to the YUI Compressor}\Yahoo.Yui.Compressor.dll" />

Then add an item group to select the input css & js files, and a compressor task in the After merge event

<Target Name="AfterMerge">

<ItemGroup>
<
CssFiles Include="$(TempBuildDir)App_Themes\**\*.css;$(TempBuildDir)CSS\*.css" />
<
JavaScriptFiles Include="$(TempBuildDir)\JavaScript\*.js" />
</
ItemGroup>

<CompressorTask
CssFiles="@(CssFiles)"
DeleteCssFiles="No"
CssOutputFile="%(rootdir)%(directory)%(Filename)%(extension)"
CssCompressionType="YuiStockCompression"
JavaScriptFiles="@(JavaScriptFiles)"
ObfuscateJavaScript="FoSho"
PreserveAllSemicolons="Yeah"
DisableOptimizations="Nope"
EncodingType="Default"
DeleteJavaScriptFiles="No"
JavaScriptOutputFile="%(rootdir)%(directory)%(Filename)%(extension)"
LoggingType="ALittleBit" />

</Target>

 

More information about the MSBuild selectors, commands, ...: http://msdn.microsoft.com/en-us/library/ms171452(VS.80).aspx



Automate SQL Server Express Databases Backup...

clock August 24, 2010 23:52 by author Luuuukke

No need of the SQL Agent... Just schedule a task in windows, to execute a SQL script and a vb script ... Cool
http://www.mssqltips.com/tip.asp?tip=1486

 



Visual Studio 2010 cool features, tips & tricks...

clock August 21, 2010 10:40 by author Luuuukke

An excellent article on Visual Studio 2010 new features, and asp.NET 4 ,
a lot of tips to improve your development environment.

Personnaly i love the [tab] [tab] code snippets and the intellisense improvments,

and also, at least available, the implicit line continuation and the automatic properties

A pitty that your website needs to be in asp.NET 4 to have VB 2010 enabled,
otherwise, with say asp.NET 3.5,  it compiles in VB 9., and you get a "bla bla bla not supported in visual basic 9..." when trying to use Automatic Properties... weird Yell

 



CascadingDropDown & PersistentStatePage : restore selected values from viewstate

clock August 11, 2010 10:39 by author Luuuukke

A nice addition to the ajax controls toolkit is the CascadingDropDown adapter...

The problem is that the selected value of the dropdowns was not available after a postback,
and i needed this to restore my controls back to their state after a user postback & pageredirectsavingstate
(using a persistant page state see
http://www.codeproject.com/aspnet/persistentstatepage.asp)

the trick was easy,
save the value of dropdownlists in the viewstate after postback, before redirection

ViewState("CascadingDropDown1") = Me.CascadingDropDown1.SelectedValue
ViewState("CascadingDropDown2") = Me.CascadingDropDown2.SelectedValue

 

And then, when you come back on the page, you can eventually get your lists back at page_Prerender

Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender

If Me.IsRestoredPageState Then

Me.CascadingDropDown1.SelectedValue = ViewState("CascadingDropDown1")
Me.CascadingDropDown2.SelectedValue = ViewState("CascadingDropDown2")

End If

End Sub

 

 

That's all Smile

Well, almost...

After restoring the cascading dropdownvalues values at page_PreRender...
If you try to read the linked dropdownlists before any postback, their selectedvalues are empty !!

E.g.:

Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender

If Me.IsRestoredPageState Then

Me.CascadingDropDown1.SelectedValue = ViewState("CascadingDropDown1")
Me.CascadingDropDown2.SelectedValue = ViewState("CascadingDropDown2")

' now try to use the dropdownlist.selectedvalue
Dim val as integer = Ctype(Me.dropdownlist1.selectedvalue,integer)

' the value is empty !!!!!
' but you canread the cascadingdropdownlist adapter selected value
val  = Ctype(Me.CascadingDropDown1.selectedvalue, integer) ' Value is OK

End If

End Sub

 

OK, so you think that we can just use our CascadingDropDown selectedvalue... well, NO !
if you postback now ...

' after postback

val = Ctype(Me.dropdownlist1.selectedvalue, integer) ' gets the correct value

val  = Ctype(Me.CascadingDropDown1.selectedvalue, integer) ' CRASH
' a Value is available, but at the following text format "valueField:::TextField" !!!
' If no value is selected on the dropdownlist, the cascadingdropdown.selectedvalue returns ":::"

Finally, to get the correct value from the cascading adapter:

 If Me.CascadingDropDown1.SelectedValue.Replace(":::", "").Trim <> "" Then

val = CType(Me.ccddlEvent.SelectedValue.Split(":::")(0), Integer)

End If

 

no comment.... Sealed

 

related:
http://gandhirohan.blogspot.com/2007/09/cascadingdropdown-control.html
http://forums.asp.net/t/1232819.aspx

use cascading dropdown with a database
http://www.nerdliness.com/article/2008/02/15/using-asp-net-ajax-cascadingdropdown-visual-basic-and-database



Read / write .resx resources files programmatically

clock August 6, 2010 01:38 by author Luuuukke

To import gallery server pro .resx resources files in my custom resourceprovider database,
i had to read the GalleryServerPro.resx programmatically

Quite easy, there is a ResXResourceReader  lying in the System.Resources,
see http://www.c-sharpcorner.com/UploadFile/yougerthen/10526,2008135822PM/1.aspx

ResXResourceReader resxReader;

 

        //Create a new ResXResource reader and set the resx path to resource file path

        resxReader = new ResXResourceReader(resxPathName);

        //Enumerate the elements within the resx file and display them

        foreach (DictionaryEntry d in resxReader)

        {

            MessageBox.Show(d.Key.ToString() + " : " + d.Value.ToString());

        }

        //Close the resxReader

        resxReader.Close();

 



Visual Studio Compilation Error :

clock August 5, 2010 16:55 by author Luuuukke

I was getting a lot of error when compiling a project with a custom resource provider:

The resource object with key 'xxxxx' was not found.

cause: in my resource provider, somme calls are made to HttpContext.Current...
However, at compile time, there is NO current context... bang
http://www.hanselman.com/blog/AmIRunningInDesignMode.aspx

Solution: add a test before calling the context to see if you are in compile mode..

If Not HttpContext.Current is Nothing Then...

.. End If

 

See also: http://www.west-wind.com/weblog/posts/4008.aspx



Use different resource providers inside one application

clock August 5, 2010 16:03 by author Luuuukke

After defining a custom globalization resources provider, i had to use the standard default resourceproviderfactory (resx files) for some sub folders
 (to use Gallery server Pro App_Globalresources after integration in my application which has a custom sql reource provider)

According to some web references, and to http://msdn.microsoft.com/en-us/library/hy4kkhe0.aspx
It would be ok to set a resourceProviderFactoryType="" in the sub folder web.config..

The following default globalization element is not explicitly configured in the Machine.config file or in the root Web.config file. However, it is the default configuration that is returned by application.

<globalization requestEncoding="utf-8" 
               responseEncoding="utf-8" 
               fileEncoding="" 
               culture="" 
               uiCulture="" 
               enableClientBasedCulture="false" 
               responseHeaderEncoding="utf-8" 
               resourceProviderFactoryType="" 
               enableBestFitResponseEncoding="false" />

 

Well, nuts... it does not work, the base web.config is still used..

Another suggestion was to have your provider return null values for this subfolder or path,
as explained here http://stackoverflow.com/questions/504259/default-resource-provider-and-sqlresourceproviderfactory-in-the-same-asp-net-appl
I just got lots of errors with this solution...

I ended building a page to import resx files into my custom provider database... Undecided

 



SQL Server Express failed to retrieve text for this error Reason 15105

clock August 3, 2010 22:06 by author Luuuukke

With SQL Server Express, i had 2 different databases in the App_Data folder of an application, and i was getting constant connection errors.

After googling, i tried any solution, from changing cacls on the db folder, adding users in the sql server security, database roles, to changing identity of the iis application pool, and so on...

NOTHING Worked !

Even with 1 database alone, i was getting errors if the database was opened at the same time in visual studio and by IIS...

I ended up by regrouping the 2 databases in one,
and attached it the classic way to the server through sql server management studio.

with this connection

<

add name="mydatabase" connectionString="Server={host name}\SQLExpress;Trusted_Connection=yes;Database={Database name}"></add>

 

 



A great Theme for BlogEngine.NET : portraitpress

clock August 3, 2010 12:12 by author Luuuukke

I also migrated my personal blog (Luuuukke.com) from dasblog to BlogEngine...
No time to design my own theme, so i lazily picked up one i like in the Mega pack.
PortraitPress from OneSoft (thanks !)

There was a small bug in the site.master code, causing the header to render incorrectly


That was just a missing closing tag on an anchor in the masterpage
<div id="rss-big">
<a href="<%=Utils.FeedUrl %>" class="feed">
</div>


Adding the closing anchor tag fixed the issue.

<div id="rss-big">
<a href="<%=Utils.FeedUrl %>" class="feed"></a>
</div>

 



Sign in