/* ------------------------ My Meta Content Here SEO ------------------------ */

Pages

Main Menu

Thursday, May 29, 2014

Full path URL for images for ASP.NET

C# SOLUTION
imgLogo.Src = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + System.Web.HttpContext.Current.Request.ApplicationPath + "/images/logo.png";

How do I turn a relative URL into a full URL?

public string ConvertRelativeUrlToAbsoluteUrl(string relativeUrl)
{


return string.Format("http{0}://{1}{2}",(Request.IsSecureConnection) ? "s" : "", Request.Url.Host, Page.ResolveUrl(relativeUrl));

}

Reference:- http://ckeditor.com/forums/FCKeditor-2.x/C-SOLUTION-Full-path-URL-for-images-for-.NET-connector

Get Current Page URL Address

Request.ApplicationPath:                   /virtual_dir

Request.CurrentExecutionFilePath:  /virtual_dir/webapp/page.aspx

Request.FilePath :                              /virtual_dir/webapp/page.aspx

Request.Path :                                    /virtual_dir/webapp/page.aspx

Request.PhysicalApplicationPath :   d:\Inetpub\wwwroot\virtual_dir\

Request.QueryString :                       /virtual_dir/webapp/page.aspx?q=qvalue

Request.Url.AbsolutePath :               /virtual_dir/webapp/page.aspx

Request.Url.AbsoluteUri : http://localhost:2000/virtual_dir/webapp/page.aspx?q=qvalue

Request.Url.Host :                             localhost

Request.Url.Authority :                     localhost:80

Request.Url.LocalPath :                    /virtual_dir/webapp/page.aspx

Request.Url.PathAndQuery :            /virtual_dir/webapp/page.aspx?q=qvalue

Request.Url.Port :                             80

Request.Url.Query :                         ?q=qvalue

Request.Url.Scheme :                       http

Request.Url.Segments :                    /virtual_dir/webapp/page.aspx

Hopefully you will find this useful!

No comments:

Post a Comment

My Blog List