Reputation: 2203
I'm trying to write a method which will send an email to client which has a download link that the user can click on to download directly.
Actually I'm emulating it as a continuously running process in Global which keep sending a file to a ftp server, if there is an error with the sending, a link will be sent to admin so that he can download the file directly.
My question is how can I get the external link, for example I would like to have http://www.abc.com/temp/file.txt. I want a generic solution so that whatever the domain I change my server too, the code still work?
Thanks
Upvotes: 1
Views: 1704
Reputation: 20693
I am not sure that I understand question fully, but on IIS 7 you can get domains (IIS Bindings) defined for some site with Microsoft.Web.Administration assembly
ServerManager sman = new ServerManager(); foreach (Site iisSite in sman.Sites) { foreach (Binding bind in iisSite.Bindings) { // bind.Host - here is the site domain } }
Upvotes: 1
Reputation: 144112
ASP.NET doesn't technically "know" what the entry domains are. All it cares about are applications, which are mostly orthogonal to the authority the user is coming in on. In the context of a request thread, it knows which domain that user probably asked for, but that's all.
You can get the server-relative path by using (among other things) Control.ResolveUrl("~/path_to_file");
- from there, you'll need some config-driven way of determining what the domain should be.
Upvotes: 2