Andornot Blog

Thursday, June 28, 2007 1:30 PM

ResolveUrl vs. ResolveClientUrl

by Peter Tyrrell

The .NET Control class methods ResolveUrl and ResolveClientUrl both take a relative URL as a parameter and return relative URLs for client browser use. So what's the difference between them?

In simple terms, ResolveClientUrl returns a path relative to the current page, and ResolveUrl returns a path relative to the site root. Both methods are particularly useful when passing in a relative URL prefaced with the tilde (~) to indicate the application root.

Let's say we have an image in a layout directory, and a page which needs to pass a usable relative URL for the image to the client browser.

image http://www.andornot.com/layout/images/andornotLogo.gif

page http://www.andornot.com/Products/Default.aspx.

Here is what we would get if we called the two methods from our Default.aspx page.

Page.ResolveUrl("~/layout/images/andornotLogo.gif")
"/layout/images/andornotLogo.gif"
Page.ResolveClientUrl("~/layout/images/andornotLogo.gif")
"../layout/images/andornotLogo.gif"

There is more to it, of course, particularly since these are Control methods, not exclusively Page methods. It's pretty straightforward to see how paths relative to a page resolve, but not necessarily so obvious when the control is being instantiated in a UserControl or MasterPage.

ResolveUrl uses the Control.TemplateSourceDirectory property to do its job, and that property value is the virtual directory of the Page or UserControl that contains the current server control.

ResolveClientUrl returns a URL relative to the folder containing the source file in which the control is instantiated.

Thursday, June 28, 2007 10:36 AM

Public Hotfix Patch Available for Debugging ASP.NET on IIS7

by Administrator

Mentioned first a couple posts back, there is now a public hotfix patch available for debugging ASP.NET on IIS7 that you can download here. The reason for this post is that Scott Guthrie just wrote a post that gives a much better explanation of the problem and fix.

Wednesday, June 27, 2007 5:46 PM

Type-safe access to the current page's URL

by Ted Jardine

Virtually every web project you work on requires that you get the current page's complete URL. Years ago, I got tired of using non-type-safe ways of munging together various Request.ServerVariables to get it (anyone remember stuff like "If Request.ServerVariables("HTTPS") = "on" Then..."?) and with .NET there had to be a better way. Due to a dearth of non-Request.ServerVariables examples out there back then, it took trusty trial and error Response.Write tests and the MSDN help to settle on the following:

Request.Url.Scheme + Request.Url.SchemeDelimiter + Request.Url.Authority + Request.Url.PathAndQuery

While I never understood why I still had to parse these together (and I sporadically investigated alternatives), it nevertheless felt so much better than parsing together strings like "://" with icky stuff like Request.ServerVariables("SERVER_NAME").

But yes, there had to be an even better way: a way that resisted forgetfulness and the ensuing battle with more than vague intellisense descriptions. Since I'm slow, it was only today that I found it. My my, sometimes I do miss the obvious:

Request.Url.ToString()
returns the canonically unescaped form of the URI (i.e. "http://www.example.com:80//thick and thin.htm")

and/or

Request.Url.AbsoluteUri
Returns the canonically escaped form of the URI (i.e. http://www.example.com:80//thick%20and%20thin.htm)

And yes, I had tried out AbsoluteUri before (I must have, right?), but for some reason, I still missed it.

Tuesday, June 26, 2007 3:01 PM

WebClarity releases BookWhere version 6

by Administrator
Customers with ongoing maintenance subscriptions may download this new version for no additional charge. Check out the new features or register for one of the WebClarity product overview webinars.

BookWhere is a great tool for the ongoing cataloguing of new library material as well as retrospective conversion projects. Hundreds of library databases worldwide can be searched and their bibliographic records exported in MARC communications format. These records can then be converted using the MARC Transformer add-on product and imported into Inmagic Genie or other Inmagic textbases.

Contact Andornot for more information and pricing.
Tuesday, June 26, 2007 2:43 PM

Inmagic news releases regarding Presto software

by Administrator
Inmagic, Inc. has recently issued news releases on two Presto customers.

May 31, 2007 - Inmagic Presto Software Ensures NASA Space Shuttle Safety by Organizing and Providing Access to Critical Images
Read the press release

June 26, 2007 - R.V. Anderson Associates Limited Selects Inmagic Presto to Capture and Share Its Intellectual Capital
Read the press release

Inmagic® Presto is a Web-based enterprise application designed for organizations where managing multiple collections of information in diverse formats and locations is of strategic importance. Information-intensive organizations that use Presto typically have high-value and dynamic content that needs to be centrally managed and made available 24/7 for efficient research by a wide audience.

Please contact Andornot for further information on Presto or other Inmagic products.

Month List