ResolveUrl() from WCF service

Posted by Michael Freidgeim on Geeks with Blogs See other posts from Geeks with Blogs or by Michael Freidgeim
Published on Sat, 07 Jul 2012 10:51:01 GMT Indexed on 2012/07/10 15:17 UTC
Read the original article Hit count: 213

Filed under:

I wanted to ResolveUrl() from WCF service and found

http://www.west-wind.com/weblog/posts/2007/Sep/18/ResolveUrl-without-Page .
However the function assumes that the call is synchronous, in asynchronous call (e.g called from TPL task) HttpContext.Current==null.
I had to split my asynchronous method into two-a long asynchronous one, invoked as task and generating relative URL and a post-task, that is calling wwWebUtils.ResolveServerUrl(relativeUrL)

The http://www.codeproject.com/Articles/205425/ASP-NET-ResolveUrl-Without-Page  article suggests to use
System.Web.VirtualPathUtility.ToAbsolute("~/default.aspx");
but i expect, it wouldn’t work from asynchronous thread as well.

© Geeks with Blogs or respective owner