I wanted to create a function that returns the path to the current website. This is what I thought worked while working in the IDE:
Public Shared Function WebsiteAbsoluteBaseUrl() As String Dim RequestObject As System.Web.HttpRequest = HttpContext.Current.Request Return "http://" & RequestObject.Url.Host & ":" & _ RequestObject.Url.Port & "/" & _ RequestObject.Url.Segments(1) End Function
Does this seem to work? Is there a more direct way?
I am trying to replace all occurrences of the {{WebSiteBaseUrl} tag in an html email with an absolute website address.
<A HREF="{WebSiteBaseUrl}Files/filename.pdf/>Some Text</A>
I do not want to parse the template and try to understand it in order to use the MapPath function regarding the relative path to the file name.
The resulting email will become the html body of the html email, so I need the links to be absolute.
<a href="http://websitename:80/SubmitOrder.aspxFiles/filename.pdf" target="_blank">Some Text</a>
I assume that what I see in dev running in the IDE is that "RequestObject.Url.Segments (1)" returns the name of the virtual folder, and during production it seems to return the name of the website This is likely due to the way the website is configured in IIS.
What does this say about how the website is set up for production and how do you suggest that I change the code to get the correct path after replacing {WebSiteBaseUrl} with the result of the function? This assumes that the file "filename.pdf" is in the relative path ~ / files / filesname.pdf.
user330100
source share