日期:2014-05-20 浏览次数:20458 次
// Builds an absolute URL private static string BuildAbsolute(string relativeUri) { // get current uri Uri uri = HttpContext.Current.Request.Url; // build absolute path string app = HttpContext.Current.Request.ApplicationPath; if (!app.EndsWith("/")) app += "/"; relativeUri = relativeUri.TrimStart('/'); // return the absolute path return HttpUtility.UrlPathEncode( String.Format("http://{0}:{1}{2}{3}", uri.Host, uri.Port, app, relativeUri)); }
public static string ToProduct(string productId) { return BuildAbsolute(String.Format("Product.aspx?ProductID={0}", productId)); }